Questions tagged [standard-deviation]

Standard deviation (represented by the symbol sigma, σ) shows how much variation or "dispersion" exists from the average (mean, or expected value).

The standard deviation of a random variable, statistical population, data set, or probability distribution is the square root of its . A standard deviation close to 0 indicates that the data points tend to be very close to the mean (also called the expected value) of the set, while a high standard deviation indicates that the data points are spread out over a wider range of values.

The standard deviation of X is the quantity

enter image description here

870 questions
147
votes
8 answers

Standard deviation of a list

I want to find mean and standard deviation of 1st, 2nd,... digits of several (Z) lists. For example, I have A_rank=[0.8,0.4,1.2,3.7,2.6,5.8] B_rank=[0.1,2.8,3.7,2.6,5,3.4] C_Rank=[1.2,3.4,0.5,0.1,2.5,6.1] # etc (up to Z_rank )... Now I want to take…
physics_for_all
  • 2,193
  • 4
  • 19
  • 20
116
votes
7 answers

Weighted standard deviation in NumPy

numpy.average() has a weights option, but numpy.std() does not. Does anyone have suggestions for a workaround?
YGA
  • 9,546
  • 15
  • 47
  • 50
102
votes
3 answers

Why does numpy std() give a different result to matlab std()?

I try to convert matlab code to numpy and figured out that numpy has a different result with the std function. in matlab std([1,3,4,6]) ans = 2.0817 in numpy np.std([1,3,4,6]) 1.8027756377319946 Is this normal? And how should I handle this?
gustavgans
  • 5,141
  • 13
  • 41
  • 51
94
votes
8 answers

Standard Deviation in LINQ

Does LINQ model the aggregate SQL function STDDEV() (standard deviation)? If not, what is the simplest / best-practices way to calculate it? Example: SELECT test_id, AVERAGE(result) avg, STDDEV(result) std FROM tests GROUP BY test_id
Steven
  • 13,501
  • 27
  • 102
  • 146
73
votes
4 answers

Standard deviation of generic list?

I need to calculate the standard deviation of a generic list. I will try to include my code. Its a generic list with data in it. The data is mostly floats and ints. Here is my code that is relative to it without getting into to much detail:…
Tom Hangler
  • 783
  • 1
  • 5
  • 7
61
votes
10 answers

How can I do standard deviation in Ruby?

I have several records with a given attribute, and I want to find the standard deviation. How do I do that?
Satchel
  • 16,414
  • 23
  • 106
  • 192
46
votes
1 answer

Standard deviation in numpy

Here is my code: import numpy as np print(np.std(np.array([0,1]))) it produces 0.5 I am confident that this is incorrect. What am I doing wrong?
user1700890
  • 7,144
  • 18
  • 87
  • 183
40
votes
10 answers

Standard deviation javascript

I am trying to get the standard deviation of a user input string. I have as follows, but it returns the wrong value for SD. The calculation should go as follows: Sum values/number values = mean Square (sum each value-mean) Sum squares/number…
tc03
  • 455
  • 2
  • 5
  • 8
32
votes
5 answers

Add error bars to show standard deviation on a plot in R

For each X-value I calculated the average Y-value and the standard deviation (sd) of each Y-value x = 1:5 y = c(1.1, 1.5, 2.9, 3.8, 5.2) sd = c(0.1, 0.3, 0.2, 0.2, 0.4) plot (x, y) How can I use the standard deviation to add error bars to each…
John Garreth
  • 1,112
  • 2
  • 10
  • 17
30
votes
10 answers

Standard Deviation for SQLite

I've searched the SQLite docs and couldn't find anything, but I've also searched on Google and a few results appeared. Does SQLite have any built-in Standard Deviation function?
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
30
votes
4 answers

Compute average and standard deviation with awk

I have a 'file.dat' with 24 (rows) x 16 (columns) data. I have already tested the following awk script that computes de average of each column. touch aver-std.dat awk '{ for (i=1; i<=NF; i++) { sum[i]+= $i } } END { for (i=1; i<=NF; i++ ) {…
PLM
  • 399
  • 1
  • 3
  • 4
28
votes
3 answers

Generate random numbers with fixed mean and sd

When generating random numbers in R using rnorm (or runif etc.), they seldom have the exact mean and SD as the distribution they are sampled from. Is there any simple one-or-two-liner that does this for me? As a preliminary solution, I've created…
Jonas Lindeløv
  • 5,442
  • 6
  • 31
  • 54
27
votes
4 answers

Standard Deviation in R Seems to be Returning the Wrong Answer - Am I Doing Something Wrong?

A simple example of calculating standard dev: d <- c(2,4,4,4,5,5,7,9) sd(d) yields [1] 2.13809 but when done by hand, the answer is 2. What am I missing here?
Travis Rodman
  • 607
  • 1
  • 6
  • 14
24
votes
5 answers

How to efficiently calculate a moving Standard Deviation

Below you can see my C# method to calculate Bollinger Bands for each point (moving average, up band, down band). As you can see this method uses 2 for loops to calculate the moving standard deviation using the moving average. It used to contain an…
22
votes
4 answers

How to load extensions into SQLite?

I need a standard deviation function in SQLite. I have found one here: http://www.sqlite.org/contrib?orderby=date but its part of an extension file to SQLite. I've never installed one of these before and I don't know how to. I found this existing…
Chucky
  • 1,701
  • 7
  • 28
  • 62
1
2 3
57 58