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

    ©h

Downloads

Code


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

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

window.onload=chk;
function allnumeric(inputtxt)
{var numbers = /^[0-9]+$/; if(!inputtxt.value.match(numbers)) {
inputtxt.value = ''; }
}
function check(ad)
{
var ch=ad.value;
if(isNaN(ch))
{
var df=ch.substring(0,(ch.length-1));ad.value=df;}
}
function ck()
{alert("this");
}
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>h2 {border-bottom: 1px solid #ebebeb;color: #474747;font-size: 1.3em;font-weight: normal;line-height: 130%;}.frms{margin:0 auto;padding:10px;-moz-border-radius:.3em;-webkit-border-radius:.3em;-o-border-radius:.3em;font-family:Tahoma, Geneva, sans-serif;color:#333;font-size:.9em;line-height:1.2em;}.frms input[type="text"],[type="password"],[type="file"],textarea,select{width:99%;background:#fff;border:#ddd 1px solid;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;-o-border-radius:.35em;padding:0 .5%;margin-top:5px;margin-bottom:15px;height:35px;}.frms input:hover,textarea:hover,select:hover{box-shadow:#dae1e5 0px 0px 5px;-moz-box-shadow:#dae1e5 0px 0px 5px;-webkit-box-shadow:#dae1e5 0px 0px 5px;-o-box-shadow:#dae1e5 0px 0px 5px;}.frms input:focus,textarea:focus,select:focus{-webkit-box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);-moz-box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);border:#9d9983 1px solid;}.frms input[type="submit"],input[type="reset"],input[type="button"],button,.yellow_button,.blue_button{padding:7px 14px;font-weight:bold;color:#fff;cursor:pointer;border-radius:.3em;-moz-border-radius:.2em;-webkit-border-radius:.2em;-o-border-radius:.2em;margin:10px 0;border:none;}.frms input[type="submit"]{background:#75ab22;border-bottom:#629826 3px solid;text-shadow:#396e12 1px 1px 0px;}.frms input[type="reset"]{background:#ee765d;border-bottom:#d95e44 3px solid;text-shadow:#8c3736 1px 1px 0px;}input[type="button"],button,.blue_button{background:#468cd2;border-bottom:#3277bc 3px solid;text-shadow:#214d73 1px 1px 0px;}.frms label{font-size:1.2em;}.resp_code{margin:5px 10px 10px 300px;padding:10px 20px 10px 20px;font:normal 1em/1.3em Tahoma, Geneva, sans-serif;color:#333;background:#f8f8f8;border:#ddd 1px solid;border-radius:.25em;overflow:auto;width:50%;}@media screen and (max-width: 480px){.resp_code{width:auto !important;margin:0px !important;}.frms label{font-size:0.9em;}}
</style>
</head>
<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()'>
<input type=reset value=Reset> <span align=''center'' style="font-size: 10px;color: #dadada;" id="dumdiv"><a href="https://www.hscripts.com" id="dum" style="font-size: 10px;color: #dadada;text-decoration:none;color: #dadada;">&copy;h</a></span></div><div align='left'><label>Binomial Distribution:</label><input type=text id=b readonly></div>
</form></div>
</body>
</html>


  • Release Date - 02-04-2015
  • Get free version without ©copyright link for just $10/-
  • 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.

License

Related Scripts

Free Javascript Scripts


Ask Questions

Ask Question