http://postimg.org/image/w79si81zn/ 嗨!,我试图编写上面图片中公布的公式,但我有一个奇怪的价值,所以我想知道是否所有人都可以查看代码来看看& #39; s是我所缺少的。
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 i = 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 at " + b + " Mbps " + Math.round(p*100);
}
public static void main(String []args){
queuing x = new queuing();
System.out.println(x.math());
}
}