# A program to find standard deviation

Page 1 of 1

## 2 Replies - 288 Views - Last Post: 06 November 2010 - 11:49 PM

### #1 atik97 Reputation: 144
• Posts: 715
• Joined: 16-September 08

# A program to find standard deviation

Posted 17 January 2009 - 04:51 PM

Description: You can calculate standard deviation of a given set of data
```#A program to find standard deviation of given data
from math import *		#import math library
from Numeric import *		#import Numeric library (for array)
n=int(raw_input("Enter the number of class:"))	#Number of classes your data consists of
h=int(raw_input("Enter class interval:"))	#Class interval of your data
l=input("Enter Lower limit of first class:")
sum_f=0
sum_fmlu=0
total=0
array_a=zeros(n,Int)
array_b=zeros(n,Int)
for i in range(n):
if i==0:
l=l	#lower limit for first class
else:
l=l+h	#lower limit for other classes
print "For class-%s"%(i+1)
f=input("Frequency:")	#frequency of corresponding classes
u=l+h			#upper limit of each class
mean_ul=(l+u)/2.0	#mean of upper and lower limit
fmean_ul=f*mean_ul	#multiplication of frequency and mean
array_a[i]=mean_ul	#assigning mean to array
array_b[i]=f		#assigning frequency to array
sum_f=f+sum_f
sum_fmlu=fmean_ul+sum_fmlu
x=sum_fmlu/sum_f		#arithmetic mean value
for i in range(n):
diff=array_a[i]-x
value=pow(diff,2)*array_b[i]
total=value+total
std=sqrt(total/sum_f)		#standard deviation
print "The Standard Deviation is %f"%std

```

Is This A Good Question/Topic? 0

## Replies To: A program to find standard deviation

### #2 vidoushy Reputation: 0
• Posts: 0
• Joined: 07-November 10

## Re: A program to find standard deviation

Posted 06 November 2010 - 11:49 PM

am getting an error while using numeric

### #3 vidoushy Reputation: 0
• Posts: 0
• Joined: 07-November 10

## Re: A program to find standard deviation

Posted 06 November 2010 - 11:49 PM

am getting an error while using numeric

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }