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()Tier 1 · statistics
Sample SD
Sample standard deviation of n values.
Files (1)
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:
n:— how many values you'll enter.>— type each value one at a time,enterbetween 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}.
- Run
SAMPLESD, choose1:SD. n:→ 3.>→ 1, 2, 3 (pressingenterbetween each).- 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)
| ID | Inputs | Expected contains |
|---|---|---|
| four-all-4 | 1, 4, 2, 4, 4, 4, 0 | sd=1.0 |
| three-1-2-3 | 1, 3, 1, 2, 3, 0 | sd=1.0 |