Class PoissonDistr

java.lang.Object
org.cloudsimplus.distributions.PoissonDistr
All Implemented Interfaces:
DiscreteDistribution, StatisticalDistribution

public class PoissonDistr extends Object implements DiscreteDistribution
A Pseudo-Random Number Generator which returns numbers following a Poisson Distribution, modeling the probability of an event to happen a number of times in a given time interval.
Since:
CloudSim Plus 1.2.0 TODO There is the PoissonDistribution implementation already. This class should simply extend it, as the other class on this package do.
Author:
Manoel Campos da Silva Filho
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    PoissonDistr(double lambda)
    Creates a Poisson Pseudo-Random Number Generator to check the probability of 1 event (
    invalid reference
    k = 1
    ) to happen at each time interval.
    PoissonDistr(double lambda, long seed)
    Creates a Poisson Pseudo-Random Number Generator to check the probability of 1 event (
    invalid reference
    k = 1
    ) to happen at each time interval.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Gets the probability (Pr) to arrive
    invalid reference
    k
    events in the current time, considering the mean arrival time
    invalid reference
    lambda (λ)
    , which is represented as Pr(k events in time period).
    boolean
    Checks if at the current time,
    invalid reference
    k
    events have happened, considering the probability of these k events to happen in a time interval.
    double
    Returns the mean time between arrival of two events.
    long
     
    boolean
    Indicates if the Pseudo-Random Number Generator (RNG) applies the Antithetic Variates Technique to reduce variance of experiments using the generated numbers.
    static void
    main(String[] args)
    Tests the simulations of customer arrivals in a Poisson process.
    double
    Generate a new pseudo random number directly from the RealDistribution.sample() method.
    double
    Returns a random number that represents the next time (from current time or last generated event) that an event will happen.
    setApplyAntitheticVariates(boolean applyAntitheticVariates)
    Indicates if the Pseudo-Random Number Generator (RNG) applies the Antithetic Variates Technique to reduce variance of experiments using the generated numbers.

    Methods inherited from class java.lang.Object

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

    • PoissonDistr

      public PoissonDistr(double lambda, long seed)
      Creates a Poisson Pseudo-Random Number Generator to check the probability of 1 event (
      invalid reference
      k = 1
      ) to happen at each time interval.
      Parameters:
      lambda - the average number of events that happen at each 1 time unit. If one considers the unit as minute, this value means the average number of arrivals at each minute.
      seed - the seed to initialize the internal uniform Pseudo-Random Number Generator
      See Also:
      • invalid reference
        #setK(int)
      • setLambda(double)
    • PoissonDistr

      public PoissonDistr(double lambda)
      Creates a Poisson Pseudo-Random Number Generator to check the probability of 1 event (
      invalid reference
      k = 1
      ) to happen at each time interval.
      Parameters:
      lambda - average number of events by interval. For instance, if it was defined 1 event to be expected at each 2.5 minutes, it means that 0.4 event is expected at each minute (1/2.5).
      See Also:
      • invalid reference
        #setK(int)
  • Method Details

    • eventsArrivalProbability

      public double eventsArrivalProbability()
      Gets the probability (Pr) to arrive
      invalid reference
      k
      events in the current time, considering the mean arrival time
      invalid reference
      lambda (λ)
      , which is represented as Pr(k events in time period). It computes the Probability Mass Function (PMF) of the Poisson distribution.
      Returns:
      the probability of a random variable to be equal to k
      See Also:
    • eventsHappened

      public boolean eventsHappened()
      Checks if at the current time,
      invalid reference
      k
      events have happened, considering the probability of these k events to happen in a time interval.
      Returns:
      true if k events have happened at the current time, false otherwise
    • sample

      public double sample()
      Returns a random number that represents the next time (from current time or last generated event) that an event will happen. That time is computed based on events arrival rate defined by
      invalid reference
      lambda (λ)
      . The time unit (if seconds, minutes, hours, etc.) is the same you considered when setting a value to the
      invalid reference
      lambda
      attribute.

      Calling this method for the first time returns the next event arrival time. The return values for consecutive calls can be handled in one of the following ways:

      • If you are generating all random event arrivals at the beginning of the simulation, you need to add the previous time to the next event arrival time. This way, the arrival time of the previous event is added to the next one. For instance, if consecutive calls to this method return the values 60 and 25, from the current time, that means: (i) the first event will arrive in 60 seconds; (ii) the next event will arrive in 85 seconds, that is 25 seconds after the first one.
      • If you are generating event arrivals during simulation runtime, you must NOT add the previous time to the generated event time, just use the returned value as the event arrival time.

      Poisson inter-arrival times are independent and identically distributed exponential random variables with mean 1/λ.

      Specified by:
      sample in interface StatisticalDistribution
      Returns:
      a random number that represents the next time (from current time or last generated event) that an event will happen
      See Also:
    • getSeed

      public long getSeed()
      Specified by:
      getSeed in interface StatisticalDistribution
      Returns:
      the seed used to initialize the generator
    • isApplyAntitheticVariates

      public boolean isApplyAntitheticVariates()
      Description copied from interface: StatisticalDistribution
      Indicates if the Pseudo-Random Number Generator (RNG) applies the Antithetic Variates Technique to reduce variance of experiments using the generated numbers.

      This technique doesn't work for all the cases. However, in the cases it can be applied, in order for it to work, you have to perform some actions. Consider an experiment that has to run "n" times. The first half of these experiments has to use the seeds you want. However, the second half of the experiments have to set the applyAntitheticVariates attribute to true and use the seeds of the first half of experiments.

      Thus, the first half of experiments are run using PRNGs, returning random numbers as U(0, 1)[seed_1], ..., U(0, 1)[seed_n]. The second half of experiments then uses the seeds of the first half of experiments, returning random numbers as 1 - U(0, 1)[seed_1], ..., 1 - U(0, 1)[seed_n].
      Specified by:
      isApplyAntitheticVariates in interface StatisticalDistribution
      Returns:
      true if the technique is applied, false otherwise
      See Also:
    • setApplyAntitheticVariates

      public PoissonDistr setApplyAntitheticVariates(boolean applyAntitheticVariates)
      Description copied from interface: StatisticalDistribution
      Indicates if the Pseudo-Random Number Generator (RNG) applies the Antithetic Variates Technique to reduce variance of experiments using the generated numbers.
      Specified by:
      setApplyAntitheticVariates in interface StatisticalDistribution
      Parameters:
      applyAntitheticVariates - true if the technique is to be applied, false otherwise
      See Also:
    • originalSample

      public double originalSample()
      Description copied from interface: StatisticalDistribution
      Generate a new pseudo random number directly from the RealDistribution.sample() method. This way, the Antithetic Variates Technique is ignored if enabled.

      Usually you shouldn't call this method but StatisticalDistribution.sample() instead.

      Specified by:
      originalSample in interface StatisticalDistribution
      Returns:
      the next pseudo random number in the sequence, following the implemented distribution, ignoring the Antithetic Variates Technique if enabled
    • getInterArrivalMeanTime

      public double getInterArrivalMeanTime()
      Returns the mean time between arrival of two events. It is the inverse of
      invalid reference
      lambda (λ)
      . The time unit (if seconds, minutes, hours, etc.) is the same considered when setting a value to the
      invalid reference
      lambda
      attribute.
      Returns:
      the mean time between arrival of two events
    • main

      public static void main(String[] args)
      Tests the simulations of customer arrivals in a Poisson process. All the code inside this method is just to try the class. That is why it declares internal methods as Functional objects, instead of declaring such methods at the class level and just calling them.