java - queuing networking formula -
http://postimg.org/image/w79si81zn/ hi!, i'm trying code formula posted on picture above, i'm having weird value, wondering if y'all can take @ code see what's i'm missing.
import java.util.*; public class queuing{ //get factorial int m = 20;//20 double b = .2; double p = .02; double prob = .05;//.5 int notque = 0; int not = 1-notque; double b = 0; public static int factorial(int n) { if (n <= 1) { return 1; } else { return n * factorial(n-1); } } public string math(){ while((1-notque) > prob){ b += .2;// notque = 0; double n = math.round(b/b); for(int = 0; i<=n ;i++ ){ double mfact = factorial(m);// double nfact = factorial(i);// double msns = factorial(m-i);// double ncr = (mfact)/(nfact*msns) ;//;nfact*factorial((int)msns) double pow1 = math.pow(p,i); double inactive = m-i; double pow2 = math.pow((1-p),inactive); notque += ncr * pow1 * pow2; } } return "speed of " + b + " users " + m + " transmitting @ " + b + " mbps " + math.round(p*100); } public static void main(string []args){ queuing x = new queuing(); system.out.println(x.math()); } }
Comments
Post a Comment