Open dhardy opened 1 month ago
Clippy says:
error: methods called `new` usually return `Self`
--> rand_distr/src/pert.rs:91:5
|
91 | / pub fn new(min: F, max: F) -> PertBuilder<F> {
92 | | let shape = F::from(4.0).unwrap();
93 | | PertBuilder { min, max, shape }
94 | | }
I don't think Pert::build(min, max).with_mode(mode).unwrap()
is better. (And we can't attach a .build()
there because it would allow modifying shape
after calling .with_mean(mean)
.) Shall we ignore this?
CHANGELOG.md
entry1311 show-cases an issue with our PERT implementation. The simplest fix I found was to also use the special-case of
v
when2*mode - min - max == 0
. A better fix can be found in the R package mc2d, duplicated here.Calculations are straightforward:
As the R source shows, we can easily calculate
mode
frommean
. Since our argument order (min, max, mode
) is already unusual, I replaced the constructor with a builder pattern.