List of usage examples for org.apache.mahout.math.jet.random Normal cdf
@Override public double cdf(double x)
From source file:pickleencoder.PrepareData.java
public Double[] create_gmm_histogram(Double[] p, Double[] m, Double[] s, Double[] bin_edges) { int bins = Array.getLength(bin_edges); int size = Array.getLength(p); // hist = np.zeros(bin_edges.shape[0]+1) Double[] hist = new Double[bins + 1]; Double[] temp = new Double[bins + 1]; // hist[:-1] = (norm.cdf(bin_edges[np.newaxis].T, loc = m, scale = np.sqrt(s)) * p).sum(axis = 1) for (int i = 0; i < bins; i++) { temp[i] = 0.0;//www.j av a 2s.co m // System.out.println("i" + i); for (int j = 0; j < size; j++) { Normal n = new Normal(m[j], Math.sqrt(s[j]), null); temp[i] += n.cdf(bin_edges[i]) * p[j]; } // System.out.println(temp[i]); // norm[i] = Gaussian.cdf(bin_edges[i], m[i], Math.sqrt(s[i])); } // hist[-1] = 1.0 temp[bins] = 1.0; hist[0] = temp[0]; // hist[1:] = (hist[1:] - hist[:-1]) for (int i = 1; i <= bins; i++) { // System.out.println(temp[i] + " - " + temp[i-1] + " = " + (temp[i] - temp[i-1])); hist[i] = temp[i] - temp[i - 1]; } return hist; }