Reference · Statistics
stats.pstdev
signature
stats.pstdev(list, num | null=) -> floatWhat 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.986893273527251Edge cases
- One number is enough: its deviation is
0.0, and so is a constant list's. - A second argument, a mean already known, is accepted, but the answer is the spread
about the data's own mean whatever is given, as in Python before 3.11. Leave it
out, or pass
null. - It is the square root of
stats.pvarianceexactly.
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.118033988749895trueErrors
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 pointChaining
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.0trueSee also
stats.stdev, stats.pvariance, stats.zscore, math.sqrt
Thread
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