File tree Expand file tree Collapse file tree 1 file changed +0
-30
lines changed Expand file tree Collapse file tree 1 file changed +0
-30
lines changed Original file line number Diff line number Diff line change @@ -318,36 +318,6 @@ where
318318 } )
319319 }
320320 }
321-
322- /// Construct a new `Dirichlet` with the given shape parameter `alpha` and `size`.
323- ///
324- /// Requires `size >= 2`.
325- #[ inline]
326- pub fn new_with_size ( alpha : F , size : usize ) -> Result < Dirichlet < F > , Error > {
327- if !( alpha > F :: zero ( ) ) {
328- return Err ( Error :: AlphaTooSmall ) ;
329- }
330- if size < 2 {
331- return Err ( Error :: SizeTooSmall ) ;
332- }
333- if alpha <= NumCast :: from ( 0.1 ) . unwrap ( ) {
334- // Use the Beta method when alpha is less than 0.1 This
335- // threshold provides a reasonable compromise between using the faster
336- // Gamma method for as wide a range as possible while ensuring that
337- // the probability of generating nans is negligibly small.
338- let dist = DirichletFromBeta :: new ( & vec ! [ alpha; size] )
339- . map_err ( |_| Error :: FailedToCreateBeta ) ?;
340- Ok ( Dirichlet {
341- repr : DirichletRepr :: FromBeta ( dist) ,
342- } )
343- } else {
344- let dist = DirichletFromGamma :: new ( & vec ! [ alpha; size] )
345- . map_err ( |_| Error :: FailedToCreateGamma ) ?;
346- Ok ( Dirichlet {
347- repr : DirichletRepr :: FromGamma ( dist) ,
348- } )
349- }
350- }
351321}
352322
353323impl < F > MultiDistribution < F > for Dirichlet < F >
You can’t perform that action at this time.
0 commit comments