-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathstat_normal_cdf.m
48 lines (45 loc) · 1.12 KB
/
stat_normal_cdf.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
function y = normal_cdf(x,mu,sigma)
% normal_cdf - Normal cumulative distribution function (cdf)
%
% Synopsis:
% y = normal_cdf(x)
% y = normal_cdf(x,mu,sigma)
%
% Arguments:
% x: [m n] matrix. Argument for the normal cdf
% mu: [m n] matrix. Mean value of the normal distribution. Default value: 0
% sigma: [m n] matrix. Standard deviation of the normal distribution. Default
% value: 1
%
% Returns:
% y: Scalar, value of the normal cdf (range [0,1])
%
% Description:
% The cumulative distribution function is the integral of the "Gaussian
% bump" from -inf to argument x. If non-scalar arguments are
% given, the cdf is computed for each entry.
%
%
% Examples:
% normal_cdf(0)
% returns 0.5, the value of the cdf for the standard normal
% distribution.
% normal_cdf(4, 1)
% returns 0.99865, assuming a normal distribution with mean 1.
%
% See also: normal_invcdf,erf
%
% Author(s), Copyright: Anton Schwaighofer, Jun 2005
if nargin<3,
sigma = [];
end
if isempty(sigma),
sigma = 1;
end
if nargin<2,
mu = [];
end
if isempty(mu),
mu = 0;
end
y = 0.5*erf((x-mu)./(sqrt(2).*sigma)) + 0.5;