Class PoissonDistr
- All Implemented Interfaces:
DiscreteDistribution,StatisticalDistribution
- Since:
- CloudSim Plus 1.2.0
TODO There is the
PoissonDistributionimplementation 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
ConstructorsConstructorDescriptionPoissonDistr(double lambda) Creates a Poisson Pseudo-Random Number Generator to check the probability of 1 event () to happen at each time interval.invalid reference
k = 1PoissonDistr(double lambda, long seed) Creates a Poisson Pseudo-Random Number Generator to check the probability of 1 event () to happen at each time interval.invalid reference
k = 1 -
Method Summary
Modifier and TypeMethodDescriptiondoubleGets the probability (Pr) to arriveevents in the current time, considering the mean arrival timeinvalid reference
k, which is represented asinvalid reference
lambda (λ)Pr(k events in time period).booleanChecks if at the current time,events have happened, considering theinvalid reference
kprobability of these k eventsto happen in a time interval.doubleReturns the mean time between arrival of two events.longgetSeed()booleanIndicates if the Pseudo-Random Number Generator (RNG) applies the Antithetic Variates Technique to reduce variance of experiments using the generated numbers.static voidTests the simulations of customer arrivals in a Poisson process.doubleGenerate a new pseudo random number directly from theRealDistribution.sample()method.doublesample()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.
-
Constructor Details
-
PoissonDistr
public PoissonDistr(double lambda, long seed) Creates a Poisson Pseudo-Random Number Generator to check the probability of 1 event () to happen at each time interval.invalid reference
k = 1- 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:
-
PoissonDistr
public PoissonDistr(double lambda) Creates a Poisson Pseudo-Random Number Generator to check the probability of 1 event () to happen at each time interval.invalid reference
k = 1- 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:
-
-
Method Details
-
eventsArrivalProbability
public double eventsArrivalProbability()Gets the probability (Pr) to arriveevents in the current time, considering the mean arrival timeinvalid reference
k, which is represented asinvalid reference
lambda (λ)Pr(k events in time period). It computes the Probability Mass Function (PMF) of the Poisson distribution.- Returns:
- the probability of a
random variableto be equal to k - See Also:
-
eventsHappened
public boolean eventsHappened()Checks if at the current time,events have happened, considering theinvalid reference
kprobability of these k eventsto 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. The time unit (if seconds, minutes, hours, etc.) is the same you considered when setting a value to theinvalid reference
lambda (λ)attribute.invalid reference
lambdaCalling 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:
samplein interfaceStatisticalDistribution- 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:
getSeedin interfaceStatisticalDistribution- Returns:
- the seed used to initialize the generator
-
isApplyAntitheticVariates
public boolean isApplyAntitheticVariates()Description copied from interface:StatisticalDistributionIndicates 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
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].applyAntitheticVariatesattribute totrueand use the seeds of the first half of experiments.- Specified by:
isApplyAntitheticVariatesin interfaceStatisticalDistribution- Returns:
- true if the technique is applied, false otherwise
- See Also:
-
setApplyAntitheticVariates
Description copied from interface:StatisticalDistributionIndicates if the Pseudo-Random Number Generator (RNG) applies the Antithetic Variates Technique to reduce variance of experiments using the generated numbers.- Specified by:
setApplyAntitheticVariatesin interfaceStatisticalDistribution- Parameters:
applyAntitheticVariates- true if the technique is to be applied, false otherwise- See Also:
-
originalSample
public double originalSample()Description copied from interface:StatisticalDistributionGenerate a new pseudo random number directly from theRealDistribution.sample()method. This way, theAntithetic Variates Techniqueis ignored if enabled.Usually you shouldn't call this method but
StatisticalDistribution.sample()instead.- Specified by:
originalSamplein interfaceStatisticalDistribution- Returns:
- the next pseudo random number in the sequence, following the
implemented distribution, ignoring the
Antithetic Variates Techniqueif enabled
-
getInterArrivalMeanTime
public double getInterArrivalMeanTime()Returns the mean time between arrival of two events. It is the inverse of. The time unit (if seconds, minutes, hours, etc.) is the same considered when setting a value to theinvalid reference
lambda (λ)attribute.invalid reference
lambda- Returns:
- the mean time between arrival of two events
-
main
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.
-