File: random.iff

package info (click to toggle)
ifeffit 2%3A1.2.11d-15
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,332 kB
  • sloc: fortran: 35,441; ansic: 8,458; makefile: 4,727; python: 3,315; perl: 3,144; sh: 2,721; ada: 1,003; tcl: 95
file content (24 lines) | stat: -rw-r--r-- 678 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# tests of random() command and distributions

macro stats m.x
  "simple statistics for an array"
  mean     = vsum($1)/npts($1)
  variance = vsum($1*$1)/npts($1)  - mean*mean
  std_dev  = sqrt(variance)
  print ' npts, max, min,  mean, std_dev'
  print  npts($1), ceil($1), floor($1), mean, std_dev 
end macro


random(npts=4000, output=my.x, dist=normal,sigma=2.)
echo 'my.x : normal-distribution of random numbers, sigma=2:'
stats my.x

random(npts=4000,output=my.x, dist=gauss,sigma=2.)
echo 'my.x : gaussian-distribution of random numbers, sigma=2:'
stats my.x

random(npts=4000,output=my.x, dist=uniform)
echo 'my.x : uniform-distribution of random numbers:'
stats my.x