
edu.jhu.hlt.util.stats.Stats Maven / Gradle / Ivy
package edu.jhu.hlt.util.stats;
import org.apache.commons.math3.distribution.NormalDistribution;
import org.apache.commons.math3.linear.CholeskyDecomposition;
import org.apache.commons.math3.linear.MatrixUtils;
import org.apache.commons.math3.linear.RealMatrix;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well44497b;
import edu.jhu.hlt.optimize.function.Function;
import edu.jhu.prim.util.random.Prng;
import edu.jhu.prim.vector.IntDoubleDenseVector;
import edu.jhu.prim.vector.IntDoubleVector;
/**
*
* A collection of handy stats methods.
*
* @author noandrews
*
*/
public class Stats {
public static class SampleLikelihood {
double [] theta;
double value;
public SampleLikelihood(double [] theta, double value) {
this.theta = theta;
this.value = value;
}
}
/**
* @return Vector of iid normally distributed random variables
*/
public static double [] getNormalVector(int D) {
RandomGenerator rng = new Well44497b(Prng.nextLong());
double [] ret = new double[D];
NormalDistribution N = new NormalDistribution(rng, 0, 1, 1e-6);
for(int i=0; i hh) {
return new SampleLikelihood(xx_prop.getColumnVector(0).toArray(), cur_lnpdf);
}
// Shrink slice to rejected point
if(phi > 0) {
phi_max = phi;
} else if(phi < 0) {
phi_min = phi;
} else {
throw new RuntimeException("Shrunk to current position and still not acceptable");
}
// Propose new angle difference
phi = Prng.nextDouble()*(phi_max - phi_min) + phi_min;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy