1classdef Geometric < DiscreteDistribution
2 % A Geometric probability distribution
4 % The distribution of the number of Bernoulli trials needed to get
7 % Copyright (c) 2018-2022, Imperial College London
11 function self = Geometric(p)
13 self@DiscreteDistribution(
'Geometric',1,[1,Inf]);
14 % Construct a geometric distribution with probability p
16 setParam(self, 1,
'p', p);
19 function ex = getMean(self)
22 % Get distribution mean
23 p = self.getParam(1).paramValue;
28 function SCV = getSCV(self)
31 % Get distribution squared coefficient of variation (SCV = variance / mean^2)
32 p = self.getParam(1).paramValue;
37 function X = sample(self, n)
42 % Get n samples from the distribution
43 p = self.getParam(1).paramValue;
45 X = ceil(log(1-r) ./ log(1-p));
48 function Ft = evalCDF(self,k)
49 % FT = EVALCDF(SELF,K)
51 % Evaluate the cumulative distribution function at t
54 p = self.getParam(1).paramValue;
58 function L = evalLST(self, s)
60 % Evaluate the Laplace-Stieltjes transform of the distribution function at s
61 % For Geometric(p), LST(s) = p*e^(-s) / (1 - (1-p)*e^(-s))
63 p = self.getParam(1).paramValue;
65 L = (p * e_neg_s) / (1 - (1 - p) * e_neg_s);
68 function pr = evalPMF(self, k)
71 % Evaluate the probability mass function at k
74 p = self.getParam(1).paramValue;
78 function proc = getProcess(self)
81 % Get process representation for non-Markovian distribution
82 % Returns [mean, SCV] pair for use in network analysis
83 proc = [self.getMean(), self.getSCV()];