Android Open Source - dice-probabilities Distribution






From Project

Back to project page dice-probabilities.

License

The source code is released under:

MIT License

If you think the Android project dice-probabilities listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.kleemann.diceprobabilities.distribution;
/*w ww  .  j  av  a 2s  . c o  m*/
import org.apache.commons.math3.fraction.BigFraction;

/**
 * <p>
 * Represents a discrete distribution that exists over the integer set 0 to
 * size()-1 A distribution consists of discrete events (x values) that have a
 * probability (returned by getProbability(y)) that each have an independent
 * probability. Independence means:
 * 
 * <p>
 * <ol>
 * 
 * <li>only one event can happen.
 * 
 * <li>one event is guaranteed to happen.
 * 
 * </ol>
 * 
 * <p>
 * A side effect of this is that all probabilities in a distribution must add up
 * to 100% (one)
 * 
 * <p>
 * In addition to the probability of event x it also can be useful to look at
 * the Cumulative probability which is the probability that an event greater
 * than or equal to x occurs. This is returned by getCumulativeProbability(x)
 * 
 * <p>
 * All our implementations of Distribution are immutable and thus thread-safe
 */
public interface Distribution {

  /**
   * Although the distribution returns legal values across all integers, it is
   * guaranteed that there are no non-zero values in the range of lowerBound()
   * to upperBound()-1. This can help with enumeration.
   */
  int lowerBound();

  int upperBound();

  /**
   * <p>
   * Returns the probability of the event at the point x. There is no range
   * for x so "out of bounds" values return a probability of zero.
   * 
   * <p>
   * Note: x values in this application generally represent sums of dice
   * rolls.
   * 
   * <p>
   * For all implementations of Distribution this method runs in constant
   * time; O(1)
   */
  BigFraction getProbability(int x);

  /**
   * <p>
   * Returns the sum of all probabilities in this distribution from point x
   * and greater.
   * 
   * <p>
   * This usually indicates succeeding at a roll where the target is x.
   * 
   * <p>
   * Some implementations run in constant time some in linear time. If many
   * calls to this function are made, call cacheCumulative()
   */
  BigFraction getCumulativeProbability(int x);

  /**
   * <p>
   * If the function getCumulativeProbability(x) of this object has worse
   * performance than O(1) then a Distribution will be returned that has
   * performance of O(1). If the current object already has O(1) performance
   * then it will return itself.
   * 
   * <p>
   * If you are going to call getCumulativeProbability(x) many times then you
   * should call this function first.
   */
  Distribution cacheCumulative();

  /**
   * <p>
   * A handy way to test if the distribution is zero. e.g.
   * ConstantDistribution.ZERO or new ConstantDistribution(0)
   */
  boolean isZero();
}




Java Source Code List

com.asolutions.widget.RowLayout.java
org.kleemann.diceprobabilities.Check.java
org.kleemann.diceprobabilities.ConstantCurrentDicePile.java
org.kleemann.diceprobabilities.CurrentDicePile.java
org.kleemann.diceprobabilities.DiceSet.java
org.kleemann.diceprobabilities.MainActivity.java
org.kleemann.diceprobabilities.PoolDicePile.java
org.kleemann.diceprobabilities.TargetPool.java
org.kleemann.diceprobabilities.Target.java
org.kleemann.diceprobabilities.distribution.AbstractDistribution.java
org.kleemann.diceprobabilities.distribution.CachedCumulativeDistribution.java
org.kleemann.diceprobabilities.distribution.ConstantDistribution.java
org.kleemann.diceprobabilities.distribution.CritDistribution.java
org.kleemann.diceprobabilities.distribution.DeathZoneDieDistribution.java
org.kleemann.diceprobabilities.distribution.DieDistribution.java
org.kleemann.diceprobabilities.distribution.Distribution.java
org.kleemann.diceprobabilities.distribution.DogslicerDistribution.java
org.kleemann.diceprobabilities.distribution.ScaleCumulativeDistribution.java
org.kleemann.diceprobabilities.distribution.SumDistribution.java
org.kleemann.diceprobabilities.graph.GraphView.java
org.kleemann.diceprobabilities.graph.Interpolate.java
org.kleemann.diceprobabilities.graph.Point.java
org.kleemann.diceprobabilities.graph.Vector.java
org.kleemann.diceprobabilities.special.AbstractSpecial.java
org.kleemann.diceprobabilities.special.CritSpecial.java
org.kleemann.diceprobabilities.special.DeathZoneSpecial.java
org.kleemann.diceprobabilities.special.DogslicerSpecial.java
org.kleemann.diceprobabilities.special.FailureSpecial.java
org.kleemann.diceprobabilities.special.ForcedRerollSpecial.java
org.kleemann.diceprobabilities.special.ModifyEachDieSpecial.java
org.kleemann.diceprobabilities.special.NormalSpecial.java
org.kleemann.diceprobabilities.special.SecondChanceSpecial.java
org.kleemann.diceprobabilities.special.SpecialSpinner.java
org.kleemann.diceprobabilities.special.Special.java