-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathNormCDFinv.m
More file actions
41 lines (38 loc) · 1.22 KB
/
NormCDFinv.m
File metadata and controls
41 lines (38 loc) · 1.22 KB
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
%% Inverse cumulative distribution function for the Normal distribution.
% Analytic equivalent of sorting a realisation of N Normally distributed
% random variables.
%
% ARGUMENTS:
% X -- vector of points at which to evaluate the distribution (0-1)
% mu(default=0) -- mean of the distribution
% sigma(default=1) -- standard deviation of the distribution
%
% OUTPUT:
% G -- Inverse CDF for a Normal probability distribution function
% evaluated at the points specified by X, normailised to unit area.
%
% USAGE:
%{
N = 200;
step = (1-(1/N))/N
X = step:step:(1-step); %
G = NormCDFinv(X);
figure, plot(X,G)
%}
%
% MODIFICATION HISTORY:
% SAK(09-09-2009) -- Original.
% SAK(Nov 2013) -- Move to git, future modification history is
% there...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function CDFinv = NormCDFinv(X,mu,sigma)
% Set defaults if all arguments not supplied...
if nargin < 2,
mu = 0; % default to mean zero
end
if nargin < 3,
sigma = 1; % default to standard deviation 1
end
%
CDFinv = mu + sigma*sqrt(2)*erfinv(2*X-1);
end %function NormCDFinv()