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

@@ -1,6 +1,6 @@
use std::f32;
use std::f64;
fn erfc(x: f32) -> f32 {
fn erfc(x: f64) -> f64 {
let z = x.abs();
let t = 1.0 / (1.0 + z / 2.0);
let r = t
@@ -21,10 +21,10 @@ fn erfc(x: f32) -> f32 {
}
}
pub fn cdf(x: f32) -> f32 {
0.5 * erfc(-x / 2.0f32.sqrt())
pub fn cdf(x: f64) -> f64 {
0.5 * erfc(-x / 2.0f64.sqrt())
}
pub fn pdf(x: f32) -> f32 {
1.0 / (2.0 * f32::consts::PI).sqrt() * (-((x / 1.0).powi(2) / 2.0)).exp()
pub fn pdf(x: f64) -> f64 {
1.0 / (2.0 * f64::consts::PI).sqrt() * (-((x / 1.0).powi(2) / 2.0)).exp()
}