Package cc.mallet.util

Examples of cc.mallet.util.Randoms


      typeTopicCounts[type] = new int[ Math.min(numTopics, typeTotals[type]) ];
    }
   
    doc = 0;

    Randoms random = null;
    if (randomSeed == -1) {
      random = new Randoms();
    }
    else {
      random = new Randoms(randomSeed);
    }

    for (Instance instance : training) {
      doc++;

      FeatureSequence tokens = (FeatureSequence) instance.getData();
      LabelSequence topicSequence =
        new LabelSequence(topicAlphabet, new int[ tokens.size() ]);
     
      int[] topics = topicSequence.getFeatures();
      for (int position = 0; position < topics.length; position++) {

        int topic = random.nextInt(numTopics);
        topics[position] = topic;
       
      }

      TopicAssignment t = new TopicAssignment (instance, topicSequence);
View Full Code Here


        // some docs may be missing at the end due to integer division
        if (thread == numThreads - 1) {
          docsPerThread = data.size() - offset;
        }
       
        Randoms random = null;
        if (randomSeed == -1) {
          random = new Randoms();
        }
        else {
          random = new Randoms(randomSeed);
        }

        runnables[thread] = new WorkerRunnable(numTopics,
                             alpha, alphaSum, beta,
                             random, data,
                             runnableCounts, runnableTotals,
                             offset, docsPerThread);
       
        runnables[thread].initializeAlphaStatistics(docLengthCounts.length);
       
        offset += docsPerThread;
     
      }
    }
    else {
     
      // If there is only one thread, copy the typeTopicCounts
      //  arrays directly, rather than allocating new memory.

      Randoms random = null;
      if (randomSeed == -1) {
        random = new Randoms();
      }
      else {
        random = new Randoms(randomSeed);
      }

      runnables[0] = new WorkerRunnable(numTopics,
                        alpha, alphaSum, beta,
                        random, data,
View Full Code Here

  public PolylingualTopicModel (int numberOfTopics) {
    this (numberOfTopics, numberOfTopics);
  }
 
  public PolylingualTopicModel (int numberOfTopics, double alphaSum) {
    this (numberOfTopics, alphaSum, 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

  }

  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

    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

  public void testLogSample ()
  {
    Variable v = new Variable (2);
    double[] vals = new double[] { -30, 0 };
    LogTableFactor ptl = LogTableFactor.makeFromLogValues (v, vals);
    int idx = ptl.sampleLocation (new Randoms (43));
    assertEquals (1, idx);
  }
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.