Reference · Statistics

stats.pstdev

signature
stats.pstdev(list, num | null=) -> float

What it does

The population standard deviation of a list of numbers: the square root of stats.pvariance, as Python's statistics.pstdev. It is in the data's own units, where the variance is in their square. For a sample of a larger population use stats.stdev.

Examples

print(stats.pstdev([1, 2, 3, 4]))print(stats.pstdev([1.5, 2.5, 2.5, 2.75, 3.25, 4.75]))
output
1.1180339887498950.986893273527251

Edge cases

print(stats.pstdev([5]), stats.pstdev([7, 7, 7]))print(stats.pstdev([1, 2, 3, 4], 0), stats.pstdev([1, 2, 3, 4], null))print(stats.pstdev([1, 2, 3, 4]) == math.sqrt(stats.pvariance([1, 2, 3, 4])))
output
0.0 0.01.118033988749895 1.118033988749895true

Errors

No data is a runtime error, not an error value: an empty list or null stops the request. So does an item that is not a number.

this one fails
print(stats.pstdev([]))
output
line 1: `stats.pstdev` requires at least one data point

Chaining

let xs = [2, 4, 4, 4, 5, 5, 7, 9]print(xs | stats.pstdev)print((xs | map((x) => (x - stats.mean(xs)) / stats.pstdev(xs))) == stats.zscore(xs))
output
2.0true

See also

stats.stdev, stats.pvariance, stats.zscore, math.sqrt

Thread
7Useful? Like it, or add to its thread below.

Thread 0 posts

On stats.pstdev(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo