-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhardcoded_pdf.m
44 lines (37 loc) · 950 Bytes
/
hardcoded_pdf.m
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
% Density function function for hardcoded in spearate m-files
%
% P = HARDCODED_PDF(x, ID, shift, scale)
%
%INPUT
% x value at which we are interested in the cdf value, P(X<x)
% ID ID value of the distribution (specified in probdata.marg)
% shift shift parameter /default = 0/
% scale scale parameter /default = 1/
%
%OUTPUT
% P density value at x
%
%NOTE:
function [P, x_grid, pdf] = hardcoded_pdf(x, ID, shift, scale)
if nargin < 4
scale = 1;
end
if nargin < 3
shift = 0;
end
switch ID
case 201 % wind
x_grid = wind_x_grid;
pdf = wind_pdf;
case 301 % snow
x_grid = snow_x_grid;
pdf = snow_pdf;
case 1001 % dummy1
x_grid = dummy1_x_grid;
pdf = dummy1_pdf;
otherwise
error(['Unknown ID: ', num2str(ID)])
end
xx = (x - shift)/scale;
P = 1/scale*interp1(x_grid, pdf, xx);
end