-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_continuous.m
55 lines (46 loc) · 949 Bytes
/
example_continuous.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
45
46
47
48
49
50
51
52
53
54
55
clc
clear
close all
reset(symengine)
tic
%Uniform
a = 2;
b = 4;
fCDF = @(x) (x-a)/(b-a) * heaviside(x-a)*heaviside(b-x) + heaviside(x-b);
X = 0:6;
CDF = zeros(1,numel(X));
syms t
CF = (exp(1i*t*b) - exp(1i*t*a))/(1i*t*(b-a));
parfor j=1:numel(X)
CDF(j) = Davies_inversion_continuous( CF, X(j) );
end
figure;
hold on
plot(X,arrayfun(fCDF,X),'DisplayName','Analytical');
plot(X,CDF,'x:','DisplayName','Numerical');
title('Uniform');
legend('show');
hold off
%Gamma
k = 9;
theta = 0.5;
fCDF = @(x) gammainc(x/theta,k,'lower');
X = 0:0.1:10;
CDF = zeros(1,numel(X));
syms t
CF = (1-theta*1i*t)^-k;
parfor j=1:numel(X)
CDF(j) = Davies_inversion_continuous( CF, X(j) );
end
figure;
hold on
plot(X,arrayfun(fCDF,X),'DisplayName','Analytical');
plot(X,CDF,'x:','DisplayName','Numerical');
legend('show');
title('Gamma');
hold off
elapsedTime = toc;
s = seconds(elapsedTime);
s.Format = 'hh:mm:ss.SSS';
disp('Elapsed time (hms): ');
disp(s);