Hi all -

While browsing the J NuVoc page I accidentally stumbled upon this example:

URL: http://code.jsoftware.com/wiki/Vocabulary/ampdotco

Under "Common Uses / 2. Compute standard deviation as the root-mean-square of a list of differences from the mean value"
the example starts out  with

y =: 0 _2 1 2          NB. list of differences from the mean value

This didn't look right to me as the sum of deviations does not result in zero:

   +/ 0 _2 1 2
1

So I made up an example myself:

   obs=. 5 2 6 7     NB. observed data
   amean=. +/ % #     NB. arithmetic mean
   dev=. ] - amean     NB. deviation from mean value
   dev obs
0 _3 1 2

Comparing this result with the above (original set of deviations)
makes me think it might be a typo.

The "mean deviation" (mean of absolute deviation values) would then be

   dmean=. amean @: |
   dmean dev obs
1.5

and the standard deviation (root-mean-square of deviation values)

   stddev=. amean &.: *:
   stddev dev obs
1.87083

Would somebody please have a look into that to check whether I'm utterly wrong or not..?

Thanks
-M
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to