You are viewing a single comment's thread. Return to all comments →
static void Main(String[] args) { var zs = System.Console.ReadLine().Split(' '); double b = double.Parse(zs[0]); double g = double.Parse(zs[1]); int bs = 3; int chs = 6; double sum = 0; double pb = b / (g + b); double pg = 1.0 - pb; for(int i = bs;i<=chs;i++){ sum += comb(chs, i) * Math.Pow(pb,i) * Math.Pow(pg, (chs-i)); } System.Console.WriteLine(Math.Round(sum,3).ToString("f3")); } static double comb(double n, double r){ var nf = f(n); var rf = f(r); var nrf = f(n-r); return nf / ( rf * (nrf)); } static double f(double i) { if (i < 2){ i = 1; } double l = i; while(i-->1){ l = l*i; } return l; }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 4: Binomial Distribution I
You are viewing a single comment's thread. Return to all comments →