示例#1
0
double func2_m2n(double m)
{
  double ncen,nsat,x;
  m = exp(m);
  ncen = N_cen(m);
  nsat = N_sat(m);
  x = poisson_prob(g31_number-1,nsat);
  if(isnan(x))x = 0;
  return ncen*x*m*dndM_interp(m);
}
/* Generate a random integer based on a Poisson distribution 
 * with mean given as input.
 */
int poisson_deviate(double nave)
{
  static int flag=0;
  double p,pp;
  int n;

  p=0;
  pp=1;

  while(p<pp)
    {
      if(nave<1)
	n=(int)(drand48()*20);
      else
	n=(int)(drand48()*30*nave);
      p=poisson_prob(n,nave);
      pp=drand48();
    }
  return(n);
}