/**
   * Creates a stream of pseudo random numbers following a Hypergeometrical distribution. The
   * specific parameters N (set size), n (marked amount) and k (subset size) have to be given here
   * at creation time.
   *
   * @param owner Model : The distribution's owner
   * @param name java.lang.String : The distribution's name
   * @param setSize int : The size of the underlying set.
   * @param markedAmount int : The amount of marked objects within the underlying set.
   * @param subsetSize int : The size of the random subset of the underlying set.
   * @param showInReport boolean : Flag for producing reports
   * @param showInTrace boolean : Flag for producing trace output
   */
  public DiscreteDistHypergeo(
      Model owner,
      String name,
      int setSize,
      int markedAmount,
      int subsetSize,
      boolean showInReport,
      boolean showInTrace) {
    super(owner, name, showInReport, showInTrace);
    this.setSize = setSize;
    this.markedAmount = markedAmount;
    this.subsetSize = subsetSize;
    valueList = new ArrayList<Entry>();
    Entry e;

    HypergeometricDistribution hgdist =
        new HypergeometricDistributionImpl(setSize, markedAmount, subsetSize);
    for (int i = 0; i <= this.subsetSize; i++) {
      try {
        e = new Entry(i, hgdist.cumulativeProbability(i));
        valueList.add(e);

      } catch (MathException e1) {
        sendWarning(
            "Failed to compute cumulative Probability of value "
                + Integer.toString(i)
                + ", entry ignored",
            "CustomContDist : " + getName() + " at construction time",
            "Impossible to compute cumulative Probability",
            "Make sure the subset size as well as the amount of successes are smaller than the main set size");
      }
    }
  }
Example #2
0
  /**
   * @param param population size
   * @param param2 number of successes
   * @param param3 sample size
   * @return hypergeometric distribution
   */
  protected HypergeometricDistribution getHypergeometricDistribution(
      int param, int param2, int param3) {
    if (hypergeometric == null
        || hypergeometric.getNumberOfSuccesses() != param2
        || hypergeometric.getPopulationSize() != param
        || hypergeometric.getSampleSize() != param3)
      hypergeometric = new HypergeometricDistributionImpl(param, param2, param3);

    return hypergeometric;
  }
  public static double probabilty(
      int backgroundChipSize, int countOnBackground, int filterSetSize, int countFiltered) {

    // create the distribution
    HypergeometricDistribution dist =
        factory.createHypergeometricDistribution(
            backgroundChipSize, countOnBackground, filterSetSize);

    // return the probability
    return dist.probability(countFiltered);
  }