Struct russell_stat::DistributionLognormal
source · pub struct DistributionLognormal { /* private fields */ }
Expand description
Defines the Lognormal distribution
Implementations§
source§impl DistributionLognormal
impl DistributionLognormal
sourcepub fn new(mu_logx: f64, sig_logx: f64) -> Result<Self, StrError>
pub fn new(mu_logx: f64, sig_logx: f64) -> Result<Self, StrError>
Creates a new Lognormal distribution
§Input
mu_logx
– mean (μ) of log(x)sig_logx
– standard deviation (σ) of log(x)
Examples found in repository?
examples/distribution_lognormal.rs (line 6)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
fn main() -> Result<(), StrError> {
// generate samples
let mut rng = rand::thread_rng();
let dist = DistributionLognormal::new(0.0, 0.25)?;
let nsamples = 10_000;
let mut data = vec![0.0; nsamples];
for i in 0..nsamples {
data[i] = dist.sample(&mut rng);
}
println!("{}", statistics(&data));
// text-plot
let stations = (0..25).map(|i| (i as f64) * 0.1).collect::<Vec<f64>>();
let mut hist = Histogram::new(&stations)?;
hist.set_bar_char('✨').set_bar_max_len(30);
hist.count(&data);
println!("{:.2}", hist);
Ok(())
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DistributionLognormal
impl RefUnwindSafe for DistributionLognormal
impl Send for DistributionLognormal
impl Sync for DistributionLognormal
impl Unpin for DistributionLognormal
impl UnwindSafe for DistributionLognormal
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more