1#![warn(unused_extern_crates)]
2#![warn(
3 clippy::all,
4 clippy::imprecise_flops,
5 clippy::suboptimal_flops,
6 clippy::unseparated_literal_suffix,
7 clippy::unreadable_literal,
8 clippy::option_option,
9 clippy::implicit_clone
10)]
11
12pub mod assignment;
13mod cdf;
14mod chi_square;
15pub mod dist;
16mod entropy;
17pub mod integrate;
18mod ks;
19pub mod mat;
20pub mod mh;
21mod mixture_type;
22mod perm;
23pub mod prior;
24pub mod prior_process;
25pub mod seq;
26mod simplex;
27pub mod uncertainty;
28
29mod sample_error;
30
31pub use cdf::EmpiricalCdf;
32pub use entropy::QmcEntropy;
33pub use lace_consts::rv;
34pub use mixture_type::MixtureType;
35pub use perm::L2Norm;
36pub use sample_error::SampleError;
37pub use simplex::*;
38
39use itertools::iproduct;
40use rand::Rng;
41use rv::traits::{KlDivergence, Rv};
42
43pub mod test {
44 use super::{chi_square, ks, perm};
45
46 pub use chi_square::chi_square_test;
47 pub use ks::{ks2sample, ks_test};
48 pub use perm::{gauss_kernel, gauss_perm_test, perm_test};
49}
50
51pub trait UpdatePrior<X, Fx: Rv<X>, H> {
53 fn update_prior<R: Rng>(
56 &mut self,
57 components: &[&Fx],
58 hyper: &H,
59 rng: &mut R,
60 ) -> f64;
61}
62
63impl UpdatePrior<bool, crate::rv::dist::Bernoulli, ()>
64 for crate::rv::dist::Beta
65{
66 fn update_prior<R: rand::Rng>(
67 &mut self,
68 _components: &[&crate::rv::dist::Bernoulli],
69 _hyper: &(),
70 _rng: &mut R,
71 ) -> f64 {
72 0.0
73 }
74}
75
76pub trait MixtureJsd {
78 fn mixture_jsd(&self) -> f64;
79}
80
81pub trait PairwiseKl {
83 fn pairwise_kl(&self) -> f64;
85}
86
87impl<Fx> PairwiseKl for Vec<Fx>
88where
89 Fx: KlDivergence,
90{
91 fn pairwise_kl(&self) -> f64 {
92 iproduct!(self, self).fold(0_f64, |acc, (f1, f2)| acc + f1.kl(f2))
93 }
94}