Debian Codegraph @

dwtest/discriminant_tableofreal_mahalanobis.praat

raw
1 # discriminant_tableofreal_mahalanobis.praat
2 # djmw 20100106
3
4 # This scripts calculates the amount of overlap between two normal distributions
5 # both distributions have sigma = 1
6 # mu1 = 0 and mu2 varies from 1 to 5
7
8 n = 20000
9
10 t0 = Create TableOfReal... t0 n 1
11 for i to n/2
12 Set row label (index)... i 1
13 endfor
14 for i from n/2+1 to n
15 Set row label (index)... i 2
16 endfor
17
18 for mu to 5
19 select t0
20 Formula... randomGauss ((if row < n/2 then 0 else mu fi), 1)
21 d = To Discriminant
22 for j to 2
23 select d
24 plus t0
25 t'j' = To TableOfReal (mahalanobis)... 'j' n
26 endfor
27 tt = Copy... tt
28 for nsigma to 5
29 Formula... Object_'t1'[row,col] < nsigma and Object_'t2'[row,col] < nsigma
30 nr = 0
31 for kr to n
32 if Object_'tt'[kr,1] = 1
33 nr += 1
34 endif
35 endfor
36 z12 = 0 + nsigma
37 z21 = mu - nsigma
38 expect = 0
39 if z21 < z12
40 # we have overlap
41 expect = (gaussQ (z21) - gaussQ (z12)) * n
42 endif
43 diff = nr - expect
44 printline For d='mu' and 'nsigma'-sigma: 'nr' from 'n' overlap; diff = 'diff:1' (expect = 'expect:1')
45 endfor
46 select d
47 plus t1
48 plus t2
49 plus tt
50 Remove
51 endfor