# A Program to find the mode of given data

Page 1 of 1

## 0 Replies - 137 Views - Last Post: 27 January 2009 - 10:28 AM

### #1 atik97

• ???

Reputation: 144
• Posts: 715
• Joined: 16-September 08

# A Program to find the mode of given data

Posted 27 January 2009 - 10:28 AM

Description: It will calculate the mode of given data set.
```from Numeric import *
n=int(input("Enter the number of class:"))
f=zeros(n+1,Int)      #creating empty array
lw=zeros(n,Float)    #creating empty array
h=int(input("Enter class interval:"))
for i in range(n):
print "For class %s"%(i+1)
l=int(input("Lower limit:"))
a=int(input("Frequency:"))
lw[i]=l
f[i]=a
for i in range(n):
#finds which is the modal class
if i==0:
hf=f[i]
j=1
else:
if hf>f[i]:
hf=hf
j=1
else:
hf=f[i]
j=i

mode=lw[j]+((f[j]-f[j-1])*h/(2*(f[j])-f[j-1]-f[j+1]))

print "The mode of the given data is %s"%mode
```

Is This A Good Question/Topic? 0

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; }