English

# Binomial Distribution Calculator

Binomial distribution calculator, allows you to calculate binomial probabilities without using lengthy equations.

# Features

• Use this calculator to compute the probability of number of successes in number of events.
• Binomial distribution is completely defined by two parameters which is n and p.
• Probability of success must be between 0 and 1.
• Online Javascript calculator, helps to estimate the binomial distribution in few seconds.
• Simple, flexible and responsive calculator.

# Preview

## Binomial Distribution - Calculator

Code

<!-- Script by hscripts.com -->
<!-- More scripts @www.hscripts.com -->
<html>

<title>Binomial Distribution Calculator in Javascript </title>
<script type="text/javascript">
function chk(){
var sds = document.getElementById('dum');
if(sds == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");

document.getElementById("maindiv").style.visibility="hidden";
}
var sdss = document.getElementById("dumdiv");
if(sdss == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");}
}

function allnumeric(inputtxt)
{var numbers = /^[0-9]+\$/; if(!inputtxt.value.match(numbers)) {
inputtxt.value = ''; }
}
{
if(isNaN(ch))
{
}
function ck()
}
function minmax(value)

{if(parseInt(value) > 150){alert("Enter number of events below 150");
document.getElementById("n").value='';
}}
function bin()
{var a = document.getElementById("n").value;
var b = document.getElementById("r").value;
var c = document.getElementById("p").value;
if(a == ""){alert("Enter the number of events");}
else if(b == ""){alert("Enter the number of success");}
else if(c == ""){alert("Enter the Probability of success");}

else{a=parseFloat(a);b=parseFloat(b);c=parseFloat(c);if(c>1){alert("The probability of success must be between 0 and 1");}else if(b>a){alert("Number of success r should be less than number of events n");}else{

//n!
var z=1;for(var i=a; i>=1; i--){z=z*i;}//r!
var x=1;for(var k=b;k>=1;k--){x=x*k;}

//(n-r)!
var s=a-b;var t=1;for(var j=s;j>=1;j--){t=t*j;}//PERMUTATION [ n!/(n-r)! ]
var p=z/t;
//COMBINATION [ (n!/(n-r)!) / r! ] , nCr = y ; 1-p = d ; n-r = e ; p^r=f
var y=p/x;var d=1-c;var e=a-b;var f=Math.pow(c,b);var g=Math.pow(d,e);
//BINOMIAL DISTRIBUTION
var res=y*f*g;if(res=="Infinity"){res = 0;}res=res.toFixed(7);

document.getElementById("b").value = res;}}

}
</script>
</style>
<body><div class='resp_code' id=maindiv'><div align='center'><h2>Binomial Distribution - Calculator</h2></div>
<form name=first class='frms'><div align='left'><label>Enter the number of events n:</label><input type=text id=n onkeyup="minmax(this.value),allnumeric(this)" maxlength=3></div><div align='left'><label>Enter the number of success r:</label><input type=text id=r onkeyup="allnumeric(this)" maxlength=3>
</div><div align='left'><label>Enter the Probability of success p:</label>
<input type=text id=p onkeyup=check(this) maxlength=3></div><div align=center><input type=button value=Calculate onclick='bin()'>
</form></div>
</body>
</html>

• Release Date - 02-04-2015
• For customization of this script or any script development, mail to support@hscripts.com

# Usage

• Copy and paste the above code into your HTML page.
• Run the file in your browser.
• Enter the number of events, number of success and probability of success.
• Click calculate and you will get the binomial distribution of the problem.
• If you want the functionality of this script alone, copy the code from the <script> tag and paste it in head part of HTML page where you need.