Use f64 instead.

This commit is contained in:
2018-10-23 14:59:58 +02:00
parent 1b840e737d
commit b4cce71df4
5 changed files with 38 additions and 38 deletions

View File

@@ -2,8 +2,8 @@ use std::ops;
#[derive(Clone, Copy)]
pub struct Gaussian {
pub pi: f32,
pub tau: f32,
pub pi: f64,
pub tau: f64,
}
impl Gaussian {
@@ -11,17 +11,17 @@ impl Gaussian {
Gaussian::with_pi_tau(0.0, 0.0)
}
pub fn with_pi_tau(pi: f32, tau: f32) -> Gaussian {
pub fn with_pi_tau(pi: f64, tau: f64) -> Gaussian {
Gaussian { pi, tau }
}
pub fn with_mu_sigma(mu: f32, sigma: f32) -> Gaussian {
pub fn with_mu_sigma(mu: f64, sigma: f64) -> Gaussian {
let pi = 1.0 / sigma.powi(2);
Gaussian::with_pi_tau(pi, pi * mu)
}
pub fn mu(&self) -> f32 {
pub fn mu(&self) -> f64 {
if self.pi == 0.0 {
0.0
} else {
@@ -29,7 +29,7 @@ impl Gaussian {
}
}
pub fn sigma(&self) -> f32 {
pub fn sigma(&self) -> f64 {
(1.0 / self.pi).sqrt()
}
}