# Environment for creative processing of text and numerical data

## Mixture of two normal distributions

S.Mustonen, Survo Users' Guide (1992), p. 160

### Edit field:

```   1 *
2 *`FILE CREATE SIMUDATA,4,1,64,7,10000`
3 *  Sample (N=10000) from a mixture of two normal distributions
4 *FIELDS:
5 *1 N 4 X
6 *END
7 *
8 *`VAR X TO SIMUDATA`
9 *  X=if(rnd(1)<0.7)then(X1)else(X2)
10 *  X1=probit(rnd(1))
11 *  X2=0.5*probit(rnd(1))+2
12 *........................................................................
13 *
14 *DENSITY MIXNORM(p,m1,s1,m2,s2)
15 *y(x)=c*(p/s1*exp(-0.5*((x-m1)/s1)^2)+(1-p)/s2*exp(-0.5*((x-m2)/s2)^2))
16 *     c=0.39894226
17 *`HISTO SIMUDATA,X,22`
18 *X=-6(0.2)6 XSCALE=-6(1)6 YSCALE=0(100)600
19 *FIT=[line_width(1)][BLUE],MIXNORM INIT=0.5,-1,1.5,3,1
20 *SIZE=1160,800 DEVICE=PS,EX.PS
21 *
22 *HISTO: Estimated parameters of MIXNORM:
23 *p=0.7003 (0.0125)
24 *m1=0.0302 (0.0296)
25 *s1=1.0078 (0.0193)
26 *m2=2.0096 (0.0180)
27 *s2=0.4906 (0.0137)
28 *logL=16043.3  # of function evaluations =626
29 *Correlations:
30 *                 p     m1     s1     m2     s2
31 * p           1.000  0.845  0.796  0.728 -0.707
32 * m1          0.845  1.000  0.802  0.673 -0.661
33 * s1          0.796  0.802  1.000  0.572 -0.592
34 * m2          0.728  0.673  0.572  1.000 -0.700
35 * s2         -0.707 -0.661 -0.592 -0.700  1.000
36 *Frequency distribution of X in SIMUDATA: N=10000
37 *
38 *Class midpoint   f     %    Sum     %      e       e     f     X^2
39 *      <=-3.6     0   0.0      0   0.0    1.1
40 *        -3.5     2   0.0      2   0.0    1.2
41 *        -3.3     1   0.0      3   0.0    2.4
42 *        -3.1     6   0.1      9   0.1    4.6     9.3     9     0.0
43 *        -2.9    12   0.1     21   0.2    8.2     8.2    12     1.7
44 *        -2.7    14   0.1     35   0.3   14.4    14.4    14     0.0
45 *        -2.5    22   0.2     57   0.6   24.0    24.0    22     0.2
46 *        -2.3    41   0.4     98   1.0   38.7    38.7    41     0.1
47 *        -2.1    57   0.6    155   1.6   59.9    59.9    57     0.1
48 *        -1.9    79   0.8    234   2.3   89.2    89.2    79     1.2
49 *        -1.7   135   1.4    369   3.7  127.6   127.6   135     0.4
50 *        -1.5   189   1.9    558   5.6  175.7   175.7   189     1.0
51 *        -1.3   218   2.2    776   7.8  232.5   232.5   218     0.9
52 *        -1.1   293   2.9   1069  10.7  295.8   295.8   293     0.0
53 *        -0.9   360   3.6   1429  14.3  362.0   362.0   360     0.0
54 *        -0.7   401   4.0   1830  18.3  426.0   426.0   401     1.5
55 *        -0.5   487   4.9   2317  23.2  481.9   481.9   487     0.1
56 *        -0.3   552   5.5   2869  28.7  524.3   524.3   552     1.5
57 *        -0.1   544   5.4   3413  34.1  548.6   548.6   544     0.0
58 *         0.1   554   5.5   3967  39.7  552.1   552.1   554     0.0
59 *         0.3   564   5.6   4531  45.3  535.0   535.0   564     1.6
60 *         0.5   510   5.1   5041  50.4  501.1   501.1   510     0.2
61 *         0.7   435   4.3   5476  54.8  458.7   458.7   435     1.2
62 *         0.9   406   4.1   5882  58.8  421.2   421.2   406     0.5
63 *         1.1   416   4.2   6298  63.0  405.3   405.3   416     0.3
64 *         1.3   402   4.0   6700  67.0  424.2   424.2   402     1.2
65 *         1.5   476   4.8   7176  71.8  476.3   476.3   476     0.0
66 *         1.7   564   5.6   7740  77.4  538.0   538.0   564     1.3
67 *         1.9   547   5.5   8287  82.9  570.5   570.5   547     1.0
68 *         2.1   586   5.9   8873  88.7  542.2   542.2   586     3.5
69 *         2.3   421   4.2   9294  92.9  450.6   450.6   421     1.9
70 *         2.5   336   3.4   9630  96.3  323.5   323.5   336     0.5
71 *         2.7   199   2.0   9829  98.3  199.7   199.7   199     0.0
72 *         2.9    93   0.9   9922  99.2  105.9   105.9    93     1.6
73 *         3.1    44   0.4   9966  99.7   48.4    48.4    44     0.4
74 *         3.3    18   0.2   9984  99.8   19.2    19.2    18     0.1
75 *         3.5    11   0.1   9995 100.0    6.8
76 *         3.7     4   0.0   9999 100.0    2.2
77 *         3.9     1   0.0  10000 100.0    0.7
78 *       > 4.0     0   0.0  10000 100.0    0.4    10.0    16     3.6
79 *Mean=0.623320 Std.dev.=1.267161
80 *Fitted by MIXNORM(0.7003,0.0302,1.0078,2.0096,0.4906) distribution
81 *Chi-square=27.48 df=28 P=0.4925
82 *

```