← Library
Tier 1 · statistics

Sample SD

Sample standard deviation of n values.

Files (1)
SAMPLESD.py328 bytes
def p(s):print(s)
def o1():
 p("=SD=")
 n=int(input("n:"))
 vs=[]
 for i in range(n):vs.append(float(input(">")))
 m=sum(vs)/n
 v=0.0
 for x in vs:v+=(x-m)*(x-m)
 sd=(v/(n-1))**0.5
 p("sd="+str(sd))
def menu():
 while True:
  p("=SAMPLE SD=")
  p("1:SD")
  p("0:EXIT")
  c=input("?>")
  if c=="1":o1()
  elif c=="0":break
menu()
How to use it

Computes the sample standard deviation (divides by n−1, not n). Use this for samples in AP Stats / inferential work; for a full population you'd need the population formula.

Launch SAMPLESD from prgm, choose 1:SD, then:

  1. n: — how many values you'll enter.
  2. > — type each value one at a time, enter between each.

Output is sd=. Program returns to the menu; 0:EXIT to leave.

Example problem

Find the sample standard deviation of the test scores {1, 2, 3}.

  1. Run SAMPLESD, choose 1:SD.
  2. n:3.
  3. >1, 2, 3 (pressing enter between each).
  4. Output: sd=1.0.

Verify: mean = 2. Squared deviations = (1−2)² + (2−2)² + (3−2)² = 1 + 0 + 1 = 2. Sample variance = 2/(3−1) = 1. SD = √1 = 1. ✓

TI-84 Plus CE — try before committingoff
TI-84 Plus CE



  (calculator off)

  Press ON to start.
Test cases (2)
IDInputsExpected contains
four-all-41, 4, 2, 4, 4, 4, 0sd=1.0
three-1-2-31, 3, 1, 2, 3, 0sd=1.0