From Second Life Wiki
Revision as of 11:50, 10 April 2008 by Karzita Zabaleta (Talk | contribs)

Jump to: navigation, search


Constant: integer LIST_STAT_STD_DEV = 5;

The integer constant LIST_STAT_STD_DEV has the value 5

Calculates the sample standard deviation of a list of numbers. Standard deviation is a measure of how spread out the values are, and is defined as the square root of the average of the squares of the numbers: <lsl> integer n = llListStatistics( LIST_STAT_NUM_COUNT, numList ); 1/n * llSqrt( llListStatistics( LIST_STAT_SUM_SQUARES , numList ) ); </lsl> The sample standard deviation is used when the list doesn't (or can't) include the entire set of numbers, like the mass of every prim in SL. The true standard deviation is therefore estimated by using the sample standard deviation, which is defined by, <lsl> integer n = llListStatistics( LIST_STAT_NUM_COUNT, numList ); 1/(n-1) * llSqrt( llListStatistics( LIST_STAT_SUM_SQUARES , numList ) ); </lsl> Another way to calculate the sample standard deviation is <lsl>

   list numList = [1,1,1,2,1000,1000,1000];
   integer n = llGetListLength( numList );
   float sum = 0;
   integer i;
   float mean = llListStatistics( LIST_STAT_MEAN, numList );
   for (i=0; i<n; i++) {
       float val = llList2Float( numList, i );
       float diff = val-mean;
       sum += ( diff )*( diff);
   float sample_stdev = llSqrt( sum/((float)(n-1)) ); 
   float true_stdev = llSqrt( sum/((float)n) ); 
   llOwnerSay((string)llListStatistics( LIST_STAT_STD_DEV, numList ));

} </lsl>

Related Articles


•  llListStatistics

Deep Notes

Search JIRA for related Issues


integer LIST_STAT_STD_DEV = 5;