-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnormality_test.m
36 lines (29 loc) · 1.02 KB
/
normality_test.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
function [pd, ha, pa] = normality_test (samples)
% Ali Mohammadi_INS/GNSS
% normality_test: checks if samples come from a normal distribution using
% the Anderson-Darling goodness-of-fit hypothesis test.
%
% INPUT
% samples: Nx1 samples to test.
%
% OUTPUT
% pd: probality distribution object from ProbabilityDistribution class.
% ha: = 0 => samples come from a normal distribution.
% = 1 => samples do not come from a normal distribution.
% pa: p-value.
%% Fit data to a normal disribution
pd = fitdist(samples, 'normal');
% sig = pd.sigma;
% mu = pd.mu;
% ref = randn (1000,1) * sig + mu;
%% Test normality
% Anderson-Darling goodness-of-fit hypothesis test
[ha, pa, ~, ~] = adtest (samples,'Distribution', pd);
% Other normality tests
% [hk , pk] = kstest2 (samples, ref); % Kolmogorov–Smirnov test
% [hz , pz] = ztest (samples, mu, sig)
% [ht , pt] = ttest (samples, mu)size(data)
% [hc , pc] = chi2gof(samples)
% [hj , pj] = jbtest (samples)
% [hk , pk] = kstest (samples, 'CDF', pd, 'Alpha',0.5)
end