1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::{Distribution, SampleableDistribution};
use rand::prelude::*;
use std::ops::Range;
#[derive(Clone, Debug)]
pub struct ContinuousUniform;
impl Distribution for ContinuousUniform {
type Value = f64;
type Condition = Range<f64>;
fn p_kernel(
&self,
_: &Self::Value,
_theta: &Self::Condition,
) -> Result<f64, crate::DistributionError> {
Ok(1.0)
}
}
impl SampleableDistribution for ContinuousUniform {
fn sample(
&self,
theta: &Self::Condition,
rng: &mut dyn RngCore,
) -> Result<Self::Value, crate::DistributionError> {
Ok(rng.gen_range(theta.clone()))
}
}