Java examples for java.lang:Math Function
normal-cdf(z) with mu = 0, stddev = 1
//package com.java2s; public class Main { /**/* w w w.ja v a2 s. c o m*/ * normal-cdf(z) with mu = 0, stddev = 1 */ public static double normalCdf(double z) { if (z < -8.0) { return 0.0; } if (z > 8.0) { return 1.0; } double sum = 0.0, term = z; for (int i = 3; sum + term != sum; i += 2) { sum = sum + term; term = term * z * z / i; } return 0.5 + sum * normalCdf(z); } /** * normal-cdf(z, mu, stddev) with given mu and stddev */ public static double normalCdf(double z, double mu, double sigma) { return normalCdf((z - mu) / sigma); } }