Git Product home page Git Product logo

fittingbinomialdistribution's Introduction

Fitting Binomial Distribution

Aim :

To fit binomial distribution for the given frequencey distribution

image

Software required :

PYTHON

Theory:

The binomial distribution is a discrete probability distribution. It describes the outcome of n independent trials in an experiment. Each trial is assumed to have only two outcomes, either success or failure. If the probability of a successful trial is p, then the probability of having x successful outcomes in an experiment of n independent trials is as follows.

image

The following are criteria for a frequency distribution to be a binomial distribution

  1. The experiment consists of n repeated trials.
  2. Each trial can result in just two possible outcomes (a success anda failure).
  3. The trials are independent (the outcome on one trial does not affect the outcome on other trials).









Procedure :

image

Program:

PROGRAM DEVELOPED BY: R.SOMEASVAR
REGISTER NUMBER: 212221230103
import numpy as np
import math
import scipy.stats

X=[0,1,2,3,4,5,6]
f=[13,25,52,68,32,16,4]
n=6
N=np.sum(f)
mean=np.inner(X,f)/N
p=mean/n
q=1-p
Pr=list(); E=list(); xi=list()
print("  X P(X=x) Obs.Fr  Ex.Fre   xi ")
print("----------------------------------")
for x in range(7):
   c=math.factorial(n)/(math.factorial(x)*math.factorial(n-x))
   Pr.append(c*p**x*q**(n-x))
   E.append(Pr[x]*N)
   xi.append((f[x]-E[x])**2/E[x])
   print("%2.2f %2.2f  %4.2f   %3.2f  %3.2f"%(x,Pr[x],f[x],E[x],xi[x]))
print("----------------------------------")
cal_chi2=np.sum(xi)
print("Calculated value of Chi square is %4.2f"%cal_chi2)
tab_chi2=scipy.stats.chi2.ppf(1-.01, df=n)
print("Table value of Chi square at 1  level is %4.2f"%tab_chi2)
if cal_chi2<tab_chi2:
   print("The given data can be fitted in binomial distribution at 1% LOS")
else:
   print("The given data cannot be fitted in binomial distribution at 1% LOS")

Output :

OUTPUT

RESULT:

Thus, fitting poisson distribution for the given frequencey distribution is verified.

fittingbinomialdistribution's People

Contributors

someasvar avatar rameshkumar7777 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.