LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
IntervalPdfFromPH.m
1% [x,y] = IntervalPdfFromPH(alpha, A, intBounds, prec)
2%
3% Returns the approximate probability density function of a
4% continuous phase-type distribution, based on the
5% probability of falling into intervals.
6%
7% Parameters
8% ----------
9% alpha : vector, shape (1,M)
10% The initial probability vector of the phase-type
11% distribution.
12% A : matrix, shape (M,M)
13% The transient generator matrix of the phase-type
14% distribution.
15% intBounds : vector, shape (K)
16% The array of interval boundaries. The pdf is the
17% probability of falling into an interval divided by
18% the interval length.
19% If the size of intBounds is K, the size of the result is K-1.
20% prec : double, optional
21% Numerical precision to check if the input is a valid
22% phase-type distribution. The default value is 1e-14
23%
24% Returns
25% -------
26% x : matrix of doubles, shape(K-1,1)
27% The points at which the pdf is computed. It holds the center of the
28% intervals defined by intBounds.
29% y : matrix of doubles, shape(K-1,1)
30% The values of the density function at the corresponding "x" values
31%
32% Notes
33% -----
34% This method is more suitable for comparisons with empirical
35% density functions than the exact one (given by PdfFromPH).
36
37function [x, y] = IntervalPdfFromPH (alpha, A, intBounds)
38
39 global BuToolsCheckInput;
40 if isempty(BuToolsCheckInput)
41 BuToolsCheckInput = true;
42 end
43
44 if BuToolsCheckInput && ~CheckPHRepresentation(alpha, A)
45 error('IntervalPdfFromPH: Input isn''t a valid PH distribution!');
46 end
47
48 K = length(intBounds);
49 x = reshape ((intBounds(2:end) + intBounds(1:end-1)) / 2, K-1,1);
50 y = zeros(1,K-1);
51 for i=1:K-1
52 y(i) = (sum(alpha*expm(A*intBounds(i))) - sum(alpha*expm(A*intBounds(i+1))))/(intBounds(i+1)-intBounds(i));
53 end
54end