(mu1: f64, mu2: f64, sigma1: f64, sigma2: f64, p1: f64, x: f64)
| 421 | } |
| 422 | |
| 423 | pub fn cdf_mixture(mu1: f64, mu2: f64, sigma1: f64, sigma2: f64, p1: f64, x: f64) -> f64 { |
| 424 | let n1 = Normal::new(mu1, sigma1.max(1e-8)).unwrap(); |
| 425 | let n2 = Normal::new(mu2, sigma2.max(1e-8)).unwrap(); |
| 426 | p1 * n1.cdf(x) + (1.0 - p1) * n2.cdf(x) |
| 427 | } |
| 428 | |
| 429 | fn normal_pdf(x: f64, mu: f64, sigma: f64) -> f64 { |
| 430 | let s = sigma.max(1e-8); |
no outgoing calls