Class DistGeometric

All Implemented Interfaces:
Serializable

public class DistGeometric extends DistDiscrete
The Geometric distribution. The geometric distribution is the only discrete memoryless random distribution. It is a discrete analog of the exponential distribution. There are two variants, one that indicates the number of Bernoulli trials to get the first success (1, 2, 3, ...), and one that indicates the number of failures before the first success (0, 1, 2, ...). In line with Law & Kelton, the version of the number of failures before the first success is modeled here, so X ={0, 1, 2, ...}. For more information on this distribution see https://mathworld.wolfram.com/GeometricDistribution.html

Copyright (c) 2002-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.

Author:
Peter Jacobs , Alexander Verbraeck
See Also:
  • Field Summary

    Fields inherited from class nl.tudelft.simulation.jstats.distributions.Dist

    stream
  • Constructor Summary

    Constructors
    Constructor
    Description
    DistGeometric(StreamInterface stream, double p)
    Construct a new geometric distribution for a repeated set of Bernoulli trials, indicating the number of failures before the first success.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    draws the next long from the stream.
    double
    Return the probability of success for each individual trial.
    double
    probability(long observation)
    returns the probability of the observation in this particular distribution.

    Methods inherited from class nl.tudelft.simulation.jstats.distributions.Dist

    getStream, setStream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DistGeometric

      public DistGeometric(StreamInterface stream, double p)
      Construct a new geometric distribution for a repeated set of Bernoulli trials, indicating the number of failures before the first success.
      Parameters:
      stream - StreamInterface; the random number stream
      p - double; the probability of success for each individual trial
      Throws:
      IllegalArgumentException - when p <= 0 or p >= 1
  • Method Details

    • draw

      public long draw()
      draws the next long from the stream.
      Specified by:
      draw in class DistDiscrete
      Returns:
      long
    • probability

      public double probability(long observation)
      returns the probability of the observation in this particular distribution.
      Specified by:
      probability in class DistDiscrete
      Parameters:
      observation - long; the discrete observation.
      Returns:
      double the probability.
    • getP

      public double getP()
      Return the probability of success for each individual trial.
      Returns:
      double; the probability of success for each individual trial
    • toString

      public String toString()
      Overrides:
      toString in class Object