LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
Poisson.m
1classdef Poisson < DiscreteDistribution
2 % Poisson Discrete distribution for counting rare events
3 %
4 % Poisson represents the Poisson distribution with rate parameter lambda.
5 % This distribution models the number of events occurring in a fixed interval
6 % when events occur independently at a constant average rate. It is commonly
7 % used for modeling arrival counts, defects, and other rare event phenomena.
8 %
9 % @brief Poisson distribution for modeling discrete event counts
10 %
11 % Key characteristics:
12 % - Single parameter: rate lambda (average number of events)
13 % - Mean = Variance = lambda
14 % - SCV = 1/lambda (decreases as lambda increases)
15 % - Support: {0, 1, 2, 3, ...}
16 % - Limit of binomial distribution as n→∞, p→0, np→lambda
17 %
18 % The Poisson distribution is used for:
19 % - Counting arrivals in fixed time intervals
20 % - Modeling defects or failures
21 % - Call center arrival modeling
22 % - Network packet arrival counts
23 % - Population dynamics and birth processes
24 %
25 % Example:
26 % @code
27 % arrival_count = Poisson(3.5); % Average 3.5 arrivals per interval
28 % samples = arrival_count.sample(1000); % Generate counts
29 % @endcode
30 %
31 % Copyright (c) 2012-2026, Imperial College London
32 % All rights reserved.
33
34 methods
35 function self = Poisson(lambda)
36 % POISSON Create a Poisson distribution instance
37 %
38 % @brief Creates a Poisson distribution with specified rate parameter
39 % @param lambda Rate parameter (average number of events, must be positive)
40 % @return self Poisson distribution instance
41 self@DiscreteDistribution('Poisson', 1, [0,Inf]);
42 setParam(self, 1, 'lambda', lambda);
43 self.immediate = (1/lambda) < GlobalConstants.FineTol;
44 self.obj = jline.lang.processes.Exp(lambda);
45 end
46
47 function X = sample(self, n)
48 % X = SAMPLE(N)
49 % Get n samples from the distribution
50 lambda = self.getParam(1).paramValue;
51
52 % Generate uniform random variables
53 u = rand(n, 1);
54
55 % Initialize output array
56 X = zeros(n, 1);
57
58 % Compute Poisson samples using inverse transform sampling
59 for i = 1:n
60 p = exp(-lambda);
61 F = p;
62 k = 0;
63 while u(i) >= F
64 k = k + 1;
65 p = p * lambda / k;
66 F = F + p;
67 end
68 X(i) = k;
69 end
70 end
71
72 function Ft = evalCDF(self,k)
73 % FT = EVALCDF(SELF,K)
74 % Evaluate the cumulative distribution function at K
75
76 lambda = self.getParam(1).paramValue;
77 Ft = poisscdf(k, lambda);
78 end
79
80 function L = evalLST(self, s)
81 % L = EVALST(S)
82 % Evaluate the Laplace-Stieltjes transform of the distribution function at s
83 % For Poisson(λ), LST(s) = exp(λ(e^(-s) - 1))
84
85 lambda = self.getParam(1).paramValue;
86 L = exp(lambda * (exp(-s) - 1));
87 end
88
89 function mean = getMean(self)
90 lambda = self.getParam(1).paramValue;
91 mean = lambda;
92 end
93
94 function rate = getRate(self)
95 lambda = self.getParam(1).paramValue;
96 rate = 1 / lambda;
97 end
98
99 function scv = getSCV(self)
100 lambda = self.getParam(1).paramValue;
101 scv = 1.0 / lambda;
102 end
103
104 function scv = getVar(self)
105 lambda = self.getParam(1).paramValue;
106 scv = lambda;
107 end
108
109 function skew = getSkewness(self)
110 lambda = self.getParam(1).paramValue;
111 skew = sqrt(lambda);
112 end
113
114 function proc = getProcess(self)
115 % PROC = GETPROCESS()
116
117 % Get process representation for non-Markovian distribution
118 % Returns [mean, SCV] pair for use in network analysis
119 proc = [self.getMean(), self.getSCV()];
120 end
121
122 end
123
124end