private static double rndGamma1(double s){
		
		double a = 0,p = 0,uf = 0,ss=10.0,d = 0,r,x=0,small= 1e-37,w;
		if (s!=ss){
			a = 1.0-s;
			p = a/(a+s*Math.exp(-a));
			uf = p*Math.pow(small/a, s);
			d = a*Math.log(a);
			ss = s;
		}
		for(;;){
			r = generator.nextDouble();
			if (r>p){
				x = a-Math.log((1.0-r)/(1.0-p));
				w = a*Math.log(x) -d;
			}
			else if (r>uf){
				x = a*Math.pow(r/p,1/s);
				w=x;
			}
			else return 0.0;
			
			r = generator.nextDouble();
			if(1.0-r <= w && r>0.0)
				if(r*(w+1.0)>= 1.0 || - Math.log(r)<= w)
					continue;
			break;
		}
		return x;
	}