1classdef Lognormal < ContinuousDistribution
2 % The Lognormal statistical distribution
4 % Copyright (c) 2012-2026, Imperial College London
8 function self = Lognormal(mu, sigma)
9 % SELF = LOGNORMAL(MU, SIGMA)
11 % Constructs a Lognormal distribution with given mu and sigma
13 self@ContinuousDistribution(
'Lognormal',2,[0,Inf]);
15 line_error(mfilename,
'sigma parameter must be >= 0.0');
17 setParam(self, 1,
'mu', mu);
18 setParam(self, 2,
'sigma', sigma);
21 function ex = getMean(self)
24 % Get distribution mean
25 mu = self.getParam(1).paramValue;
26 sigma = self.getParam(2).paramValue;
27 ex = exp(mu+sigma*sigma/2);
30 function SCV = getSCV(self)
33 % Get distribution squared coefficient of variation (SCV = variance / mean^2)
34 mu = self.getParam(1).paramValue;
35 sigma = self.getParam(2).paramValue;
36 ex = exp(mu+sigma*sigma/2);
37 VAR = (exp(sigma*sigma)-1)*exp(2*mu+sigma*sigma);
41 function X = sample(self, n)
44 % Get n samples from the distribution
45 if nargin<2 %~exist(
'n',
'var'),
48 mu = self.getParam(1).paramValue;
49 sigma = self.getParam(2).paramValue;
50 X = lognrnd(mu,sigma,n,1);
53 function Ft = evalCDF(self,t)
54 % FT = EVALCDF(SELF,T)
56 % Evaluate the cumulative distribution function at t
58 mu = self.getParam(1).paramValue;
59 sigma = self.getParam(2).paramValue;
60 Ft = logncdf(t,mu,sigma);
63 function L = evalLST(self, s)
65 % Evaluate the Laplace-Stieltjes transform of the distribution function at s
66 % The LST of Lognormal distribution doesn
't have a simple closed form.
67 % We compute it numerically using the definition: E[e^(-sX)] = ∫₀^∞ e^(-sx) f(x) dx
68 % where f(x) is the lognormal PDF
70 mu = self.getParam(1).paramValue;
71 sigma = self.getParam(2).paramValue;
73 % Use numerical integration
74 % For practical purposes, we integrate up to a reasonable upper bound
75 upperBound = exp(mu + 5 * sigma); % covers most of the distribution
84 % Lognormal PDF: exp(-(log(x)-μ)²/(2σ²)) / (x*σ*√(2π))
85 pdf = exp(-(logx - mu)^2 / (2 * sigma^2)) / (x * sigma * sqrt(2 * pi));
86 L = L + exp(-s * x) * pdf;
93 function proc = getProcess(self)
96 % Get process representation with actual distribution parameters
97 % Returns {mu, sigma} for lognormal distribution
98 proc = {self.getParam(1).paramValue, self.getParam(2).paramValue};
103 function pa = fitMeanAndSCV(MEAN, SCV)
104 % PA = FITMEANANDSCV(MEAN, SCV)
106 % Fit distribution with given mean and squared coefficient of variation (SCV=variance/mean^2)
108 mu = log(MEAN / sqrt(c*c + 1));
109 sigma = sqrt(log(c*c + 1));
110 pa = Lognormal(mu,sigma);