use crate::State;
use crate::linalg::DefaultAllocator;
use crate::linalg::allocator::Allocator;
use crate::md::StateParameter;
use rand_distr::{Distribution, Normal};
#[derive(Copy, Clone)]
pub struct Dispersion<Distr: Distribution<f64> + Copy> {
pub param: StateParameter,
pub distr: Distr,
pub bound_min: Option<f64>,
pub bound_max: Option<f64>,
}
impl<Distr: Distribution<f64> + Copy> Dispersion<Distr> {
pub fn new(param: StateParameter, distr: Distr) -> Self {
Self {
param,
distr,
bound_min: None,
bound_max: None,
}
}
}
impl Dispersion<Normal<f64>> {
pub fn from_std_dev(param: StateParameter, std_dev: f64) -> Self {
Self::new(param, Normal::new(0.0, std_dev).unwrap())
}
pub fn from_3std_dev(param: StateParameter, std_dev: f64) -> Self {
Self::new(param, Normal::new(0.0, std_dev / 3.0).unwrap())
}
}
#[derive(Clone)]
pub struct DispersedState<S: State>
where
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
{
pub state: S,
pub actual_dispersions: Vec<(StateParameter, f64)>,
}