SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
QueueLindley.java
1package tutorial;
2
3import umontreal.ssj.stat.*;
4import umontreal.ssj.rng.*;
5import umontreal.ssj.probdist.ExponentialDist;
6
7public class QueueLindley {
8
9 RandomStream streamArr = new MRG32k3a();
10 RandomStream streamServ = new MRG32k3a();
11 Tally averageWaits = new Tally("Average waits");
12
13 public double simulate(int numCust, double lambda, double mu) {
14 double Wi = 0.0;
15 double sumWi = 0.0;
16 for (int i = 2; i <= numCust; i++) {
17 Wi += ExponentialDist.inverseF(mu, streamServ.nextDouble())
18 - ExponentialDist.inverseF(lambda, streamArr.nextDouble());
19 if (Wi < 0.0)
20 Wi = 0.0;
21 sumWi += Wi;
22 }
23 return sumWi / numCust;
24 }
25
26 public void simulateRuns(int n, int numCust, double lambda, double mu) {
27 averageWaits.init();
28 for (int i = 0; i < n; i++)
29 averageWaits.add(simulate(numCust, lambda, mu));
30 }
31
32 public static void main(String[] args) {
33 QueueLindley queue = new QueueLindley();
34 queue.simulateRuns(100, 10000, 1.0, 2.0);
35 System.out.println(queue.averageWaits.report());
36 }
37}
Extends the class ContinuousDistribution for the exponential distribution tjoh95a  (page 494) with me...
double inverseF(double u)
Returns the inverse distribution function .
Extends the abstract class RandomStreamBase by using as a backbone (or main) generator the combined m...
Definition MRG32k3a.java:46
A subclass of StatProbe.
Definition Tally.java:47
String report()
Returns a formatted string that contains a report on this probe.
Definition Tally.java:397
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...