# LIST_STAT_STD_DEV

*LSL constant*

```lsl
integer LIST_STAT_STD_DEV = 5;
```

Constant groups: [ListStatisticsOperation](/constants/groups/ListStatisticsOperation/)

Calculates the *sample* standard deviation of a list of numbers.

```lsl
float sample_standard_deviation = llListStatistics( LIST_STAT_STD_DEV, numList );
```

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 count = (integer)llListStatistics( LIST_STAT_NUM_COUNT, numList );
float standard_deviation = llSqrt( llListStatistics( LIST_STAT_SUM_SQUARES , numList ) ) / count;
```

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 count = (integer)llListStatistics( LIST_STAT_NUM_COUNT, numList );
float sample_standard_deviation = llSqrt( llListStatistics( LIST_STAT_SUM_SQUARES , numList ) ) / (count - 1);
```

Another way to calculate the sample standard deviation is

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

## See also

### Functions

- [llListStatistics](/functions/llListStatistics/)

---

*Source: [LIST STAT STD DEV](https://wiki.secondlife.com/wiki/LIST_STAT_STD_DEV) on the Second Life Wiki. Content from the Second Life Wiki article LIST STAT STD DEV (revision 1194665, 2015-01-23), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/constants/LIST_STAT_STD_DEV/
