Package cc.mallet.util

Examples of cc.mallet.util.Randoms


  public int[] getTokensPerTopic() { return tokensPerTopic; }
  public int[][] getTypeTopicCounts() { return typeTopicCounts; }

  public double evaluateLeftToRight (InstanceList testing, int numParticles, boolean usingResampling,
                     PrintStream docProbabilityStream) {
    random = new Randoms();

    double logNumParticles = Math.log(numParticles);
    double totalLogLikelihood = 0;
    for (Instance instance : testing) {
     
View Full Code Here


  public LDAHyper (int numberOfTopics) {
    this (numberOfTopics, numberOfTopics, DEFAULT_BETA);
  }
 
  public LDAHyper (int numberOfTopics, double alphaSum, double beta) {
    this (numberOfTopics, alphaSum, beta, new Randoms());
  }
View Full Code Here

    this.showTopicsInterval = interval;
    this.wordsPerTopic = n;
  }

  public void setRandomSeed(int seed) {
    random = new Randoms(seed);
  }
View Full Code Here

      LabelSequence topicSequence = new LabelSequence(topicAlphabet, new int[instanceLength(instance)]);
      if (false)
        // This method not yet obeying its last "false" argument, and must be for this to work
        sampleTopicsForOneDoc((FeatureSequence)instance.getData(), topicSequence, false, false);
      else {
        Randoms r = new Randoms();
        int[] topics = topicSequence.getFeatures();
        for (int i = 0; i < topics.length; i++)
          topics[i] = r.nextInt(numTopics);
      }
      topicSequences.add (topicSequence);
    }
    addInstances (training, topicSequences);
  }
View Full Code Here

 
 

  private void initRandom() {
    if (random == null) {
      random = new Randoms();
    }
  }
View Full Code Here

    InstanceList ilist = InstanceList.load (new File(args[0]));
    int numIterations = args.length > 1 ? Integer.parseInt(args[1]) : 1000;
    int numTopWords = args.length > 2 ? Integer.parseInt(args[2]) : 20;
    System.out.println ("Data loaded.");
    TopicalNGrams tng = new TopicalNGrams (10);
    tng.estimate (ilist, 200, 1, 0, null, new Randoms());
    tng.printTopWords (60, true);
  }
View Full Code Here

    InstanceList ilist = InstanceList.load (new File(args[0]));
    int numIterations = args.length > 1 ? Integer.parseInt(args[1]) : 1000;
    int numTopWords = args.length > 2 ? Integer.parseInt(args[2]) : 20;
    System.out.println ("Data loaded.");
    LDA lda = new LDA (10);
    lda.estimate (ilist, numIterations, 50, 0, null, new Randoms())// should be 1100
    lda.printTopWords (numTopWords, true);
    lda.printDocumentTopics (new File(args[0]+".lda"));
  }
View Full Code Here

    try {
      InstanceList instances = InstanceList.load(new File(args[0]));
      InstanceList testing = InstanceList.load(new File(args[1]));

      HierarchicalLDA sampler = new HierarchicalLDA();
      sampler.initialize(instances, testing, 5, new Randoms());
      sampler.estimate(250);
    } catch (Exception e) {
      e.printStackTrace();
    }
    }
View Full Code Here

    return new TestSuite (TestRandom.class);
  }

  public static void testAsJava ()
  {
    Randoms mRand = new Randoms ();
    java.util.Random jRand = mRand.asJavaRandom ();

    int size = 10000;
    double[] vals = new double [size];
    for (int i = 0; i < size; i++) {
      vals[i] = jRand.nextGaussian ();
View Full Code Here

    Variable v = new Variable (3);
    double[] vals = new double[] { 1, 3, 2 };
    TableFactor ptl = new TableFactor (v, vals);
    int[] sampled = new int [100];

    Randoms r = new Randoms (32423);
    for (int i = 0; i < sampled.length; i++) {
      sampled[i] = ptl.sampleLocation (r);
    }

    double sum = MatrixOps.sum (vals);
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.