use crate::Rng;
use super::{Distribution, MACHINE_EPSILON};
#[derive(Debug, Clone, Copy)]
pub struct Power {
min: f64,
shape: f64,
}
impl Power {
pub fn new(min: f64, shape: f64) -> Self {
assert!(min > 0.0, "min must be positive");
assert!(shape > 0.0, "shape must be positive");
Self { min, shape }
}
}
impl Distribution for Power {
fn sample(&self, rng: &mut Rng) -> f64 {
let u = rng.uniform_f64();
let u = if u == 1.0 { 1.0 - MACHINE_EPSILON } else { u };
self.min / (1.0 - u).powf(1.0 / self.shape)
}
}