Example #1
0
  /**
   * this method draws a sample of size endPercent-startPercent and returns the size of this sample
   * which corresponds to the number of content items
   */
  public static double drawSample(int forumID, int startPercent, int endPercent) {
    if (!distributionsPerForumMap.containsKey(
        String.valueOf(forumID) + String.valueOf(startPercent) + String.valueOf(endPercent))) {
      ForumDistribution sampledForumDistribution = new ForumDistribution();
      ArrayList<Integer> threadLengths = threadsPerForumMap.get(forumID);
      Integer numberOfThreads = threadLengths.size();
      Integer startIndex;
      if (startPercent == 0.0) {
        startIndex = 0;
      } else {
        startIndex = (int) Math.round((startPercent / (double) 100) * numberOfThreads) - 1;
      }
      Integer endIndex = (int) Math.round((endPercent / (double) 100) * numberOfThreads) - 1;

      for (int i = startIndex; i <= endIndex; i++) {
        sampledForumDistribution.addThread(threadLengths.get(i));
      }

      distributionsPerForumMap.put(
          String.valueOf(forumID) + String.valueOf(startPercent) + String.valueOf(endPercent),
          sampledForumDistribution);
      dumpDistributionToFile(sampledForumDistribution, forumID, startPercent, endPercent);

      return (double) sampledForumDistribution.getNumberOfContentItems();
    } else {
      return (double)
          distributionsPerForumMap
              .get(
                  String.valueOf(forumID)
                      + String.valueOf(startPercent)
                      + String.valueOf(endPercent))
              .getNumberOfContentItems();
    }
  }
Example #2
0
 public static double getNewThreadProb(int forumID, int startPercent, int endPercent) {
   ForumDistribution forumDistr =
       distributionsPerForumMap.get(
           String.valueOf(forumID) + String.valueOf(startPercent) + String.valueOf(endPercent));
   return forumDistr.getNumberOfThreads() / (double) forumDistr.getNumberOfContentItems();
 }