home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d5xx
/
d550
/
icalc.lha
/
ICalc
/
stat.icalc
< prev
next >
Wrap
Text File
|
1991-09-19
|
1KB
|
77 lines
#
# stat.icalc
#
# Simple one-variable statistical analysis
# (finds mean, standard deviations etc.)
#
# Demonstrates use of multi() special function.
#
#
#
# variables used:
#
# st_n number of data
#
# st_sum sum of data
#
# st_ss sum of squares
#
#
#
# functions defined:
#
# statistical reset: scl()
#
# single data entry: d(x)
#
# multiple data entry: fd(x,freq)
#
# single data deletion: deld(x)
#
# multiple data deletion: delfd(x,freq)
#
# mean of sample: mean()
#
# popn. standard dev: psd()
#
# sample standard dev: ssd()
#
#
#
# Martin W Scott, August 1991
#
silent
# Create statistical variables
st_n = st_sum = st_ss = 0
# Clear statistical variables
func scl() = (st_n = st_sum = st_ss = 0)
#data entry
func d(x) = multi(st_sum = st_sum + x,\
st_ss = st_ss + sqr(x), \
st_n = st_n+1)
func fd(x,freq) = multi(st_sum = st_sum + freq*x, \
st_ss = st_ss + freq*sqr(x), \
st_n = st_n+freq )
#data deletion
func deld(x) = fd(x,-1)
func delfd(x,freq) = fd(x,-freq)
#sample statistics
# -- sample standard deviation
func ssd() = sqrt((st_ss - sqr(st_sum)/st_n)/st_n)
# -- population standard deviation
func psd() = sqrt((st_ss - sqr(st_sum)/st_n)/(st_n-1))
# -- sample mean
func mean() = st_sum / st_n
verbose