COSMOS v7.655  COSMOSv7655
(AirShowerMC)
knbino.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine knbino (k, avn, n)
 

Function/Subroutine Documentation

◆ knbino()

subroutine knbino ( real*8  k,
real*8  avn,
integer  n 
)

Definition at line 15 of file knbino.f.

References d0, and rndc().

Referenced by csnchp().

15 ! samples n from the negative binomial distrubtion of
16 ! p(n)= (n+k-1)] / n]/(k-1)] ( a/(1+a) )** n / (1+a)**k
17 ! where a=avn/k. k should be real*8
18 ! this is for unfixed k and avn. If either or both of them are
19 ! fixed, user anothr method for faster sampling.
20 !
21  implicit none
22  real*8 k, avn
23  integer n
24 !
25  real*8 a, pn, ar, u, sum
26  integer nmax
27 !
28  a=avn/k
29  pn= 1.d0/(1.d0+a)**k
30  ar=a/(1.d0+a)
31  call rndc(u)
32  sum=pn
33  nmax=avn*15.d0
34  n=0
35  do while (sum .lt. u .and. n .lt. nmax)
36  n=n+1
37  pn= pn* (n+k-1)/n * ar
38  sum=sum+pn
39  enddo
subroutine rndc(u)
Definition: rnd.f:91
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
real(4), save a
Definition: cNRLAtmos.f:20
integer n
Definition: Zcinippxc.h:1
Here is the call graph for this function:
Here is the caller graph for this function: