Package cc.mallet.util

Examples of cc.mallet.util.Randoms


    double[] precisionMatrix = new double[ 20 * 20 ];
    for (int i=0; i<20; i++) {
      precisionMatrix[ (20 * i) + i ] = 1.0;
    }

    Randoms random = new Randoms();
    double[] scatterMatrix = getScatterMatrix(nextMVNormal(observations, mean, precisionMatrix, random));
   
    double[] priorPrecision = new double[20];
    Arrays.fill(priorPrecision, 1.0);
   
View Full Code Here


   
    double[] spd = {3.0, 0.0, -1.0,
            0.0, 3.0, 0.0,
            -1.0, 0.0, 3.0};
   
    Randoms random = new Randoms();
    double[] mean = { 1.0, 1.0, 1.0 };
    double[] lower = cholesky(spd, 3);

    for (int iter = 0; iter < 10; iter++) {
      double[] sample = nextMVNormalWithCholesky(mean, lower,
View Full Code Here

  public void testSample ()
  {
    Variable v1 = new Variable (Variable.CONTINUOUS);
    Variable v2 = new Variable (Variable.CONTINUOUS);
    Randoms r = new Randoms (2343);

    Vector mu = new DenseVector (new double[] { 1.0, 2.0 });
    Matrix var = new DenseMatrix (new double[][] {{ 0.5, 2.0 }, { 0, 1 }});
//    Matrix var = new DenseMatrix (new double[][] {{ 0.5, 2.0 }, { 2.0, 0.75 }});
View Full Code Here

  }

  public void testSample ()
  {
    Variable var = new Variable (Variable.CONTINUOUS);
    Randoms r = new Randoms (2343);
    Factor f = new UniformFactor (var, -1.0, 1.5);
    TDoubleArrayList lst = new TDoubleArrayList ();
    for (int i = 0; i < 10000; i++) {
      Assignment assn = f.sample (r);
      lst.add (assn.getDouble (var));
View Full Code Here

  }

  public void testSample ()
  {
    Variable var = new Variable (Variable.CONTINUOUS);
    Randoms r = new Randoms (2343);
    Factor f = new BetaFactor (var, 0.7, 0.5);
    TDoubleArrayList lst = new TDoubleArrayList ();
    for (int i = 0; i < 100000; i++) {
      Assignment assn = f.sample (r);
      lst.add (assn.getDouble (var));
View Full Code Here


  public void testSample2 ()
  {
    Variable var = new Variable (Variable.CONTINUOUS);
    Randoms r = new Randoms (2343);
    Factor f = new BetaFactor (var, 0.7, 0.5, 3.0, 8.0);
    TDoubleArrayList lst = new TDoubleArrayList ();
    for (int i = 0; i < 100000; i++) {
      Assignment assn = f.sample (r);
      lst.add (assn.getDouble (var));
View Full Code Here

  Randoms r;

  public ExactSampler ()
  {
    this (new Randoms ());
  }
View Full Code Here

  }

  public void testSample ()
  {
    Variable var = new Variable (Variable.CONTINUOUS);
    Randoms r = new Randoms (2343);
    Factor f = new UniNormalFactor (var, -1.0, 2.0);
    TDoubleArrayList lst = new TDoubleArrayList ();
    for (int i = 0; i < 10000; i++) {
      Assignment assn = f.sample (r);
      lst.add (assn.getDouble (var));
View Full Code Here

  }

  public void testBadVariable ()
  {
    FactorGraph fg = createBoltzmannChain (5);
    Assignment assn = fg.sampleContinuousVars (new Randoms (23423));
    FactorGraph sliced = (FactorGraph) fg.slice (assn);
    Inferencer bp = new TRP ();
    bp.computeMarginals (sliced);

    try {
View Full Code Here

    }
  }

  static FactorGraph createBoltzmannChain (int len)
  {
    Randoms r = new Randoms (3241321);

    List<Variable> vars = new ArrayList<Variable> ();
    for (int i = 0; i < len; i++) {
      Variable x_i = new Variable (2);
      x_i.setLabel ("X_"+i);
      vars.add (x_i);
    }

    List<Factor> factors = new ArrayList<Factor> (vars.size ());

    // node factors
    for (int i = 0; i < len; i++) {
      double u = r.nextUniform (-4.0, 4.0);
      factors.add (new BoltzmannUnaryFactor (vars.get (i), u));
    }

    // edge factors
    for (int i = 0; i < len-1; i++) {
View Full Code Here

TOP

Related Classes of cc.mallet.util.Randoms

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.