Skip to content

Commit ab48eb6

Browse files
committed
Merge branch 'features/distribution' into dev
2 parents a7bdcb7 + 209f182 commit ab48eb6

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

examples/dist.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,18 @@ fn example() {
6363
println!("PDF at x = mean: {}", g.pdf(0.666666));
6464
println!("PDF at x = mode: {}", g.pdf(0.5));
6565
println!("");
66+
67+
let m = 1.0;
68+
let s = 1.0;
69+
let lognorm = LogNormal(m, s);
70+
let lognorm_sample = lognorm.sample(SAMPLE_SIZE);
71+
println!("LogNormal at (m,s) = ({},{})", m, s);
72+
println!("Number of samples: {}", SAMPLE_SIZE);
73+
println!("Theoretical mean: {}", lognorm.mean());
74+
println!("Sample mean: {}", lognorm_sample.mean());
75+
println!("Theoretical var: {}", lognorm.var());
76+
println!("Sample var: {}", lognorm_sample.var());
77+
println!("PDF at x = mean: {}", lognorm.pdf(2.718281828459045));
78+
println!("PDF at x = mode: {}", lognorm.pdf(1.0));
79+
println!("");
6680
}

src/statistics/dist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ impl<T: PartialOrd + SampleUniform + Copy + Into<f64>> RNG for TPDist<T> {
698698
// }
699699
Gamma(shape, scale) => {
700700
let gamma =
701-
rand_distr::Gamma::<f64>::new((*shape).into(), (*scale).into()).unwrap();
701+
rand_distr::Gamma::<f64>::new((*shape).into(), 1f64 / (*scale).into()).unwrap();
702702
gamma.sample_iter(rng).take(n).collect()
703703
} // Gamma(a, b) => {
704704
// let a_f64 = (*a).into();

0 commit comments

Comments
 (0)