Use f64 instead.
This commit is contained in:
12
src/math.rs
12
src/math.rs
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user