''
'' cosc611HW4p1.sim
'' simc cosc611HW4p1.sim
''
PREAMBLE
define i as integer variable
define norm as real 1-dim array
define stdnorm as real 1-dim array
define chisqr as real 1-dim array
define total1 as real variable
define total2 as real variable
define total3 as real variable
define total4 as real variable
define total5 as real variable
END
MAIN
'' file output
open 3 for output, name="data.txt"
use 3 for output
reserve norm(*) as 50
reserve stdnorm(*) as 50
reserve chisqr(*) as 10
'' normal
for i=1 to 50
do
let norm(i)=normal.f(12.21, 11.6836, dim.f(seed.v))
loop
print 1 line as follows
Normal number distribution:
List norm
'' Standard Normal
for i=1 to 50
do
let stdnorm(i)=((norm(i) - 12.21) / 11.6836)
''compute total1 as sum of a(i)
loop
print 1 line as follows
Standard Normal number distribution:
List stdnorm
'' Chi Square variables
for i=1 to 10
do
let total1 = stdnorm(i)*stdnorm(i) + total1 '' 1-10
let total2 = stdnorm(i+10)*stdnorm(i+10) + total2 '' 11-20
let total3 = stdnorm(i+20)*stdnorm(i+20) + total3 '' 21 - 30
let total4 = stdnorm(i+30)*stdnorm(i+30) + total4 '' 31 - 40
let total5 = stdnorm(i+40)*stdnorm(i+40) + total5 '' 41 - 50
loop
print 1 line as follows
Chi-Square sum value:
List total1
List total2
List total3
List total4
List total5
'' end main
end