-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathget_pdf.m
More file actions
27 lines (24 loc) · 818 Bytes
/
get_pdf.m
File metadata and controls
27 lines (24 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
% This Source Code Form is subject to the terms of the Mozilla Public
% License, v. 2.0. If a copy of the MPL was not distributed with this
% file, You can obtain one at http://mozilla.org/MPL/2.0/.
% Copyright (c) 2016 Sindre Nistad
function [pdf, cdf] = get_pdf(PD, i)
%% Discription
% A function to extract the i-th probability denisity function and the
% cummulative distributiuon function of the collection PD. If i is not
% given, the pdf will be extracted from PD, as it is assumed that PD is a
% single element.
%% Check number of parameters
if nargin == 2
Dist = PD(i);
else
Dist = PD;
end
%% Get the probability density function
if isstruct(Dist)
params = num2cell(Dist.Params);
Dist = makedist(Dist.DistName, params{:});
end
pdf = @(x) Dist.pdf(x);
cdf = @(x) Dist.cdf(x);
end