1 |
* |
2 |
* $Id: npoiss.F,v 3.1.1.1 2002/07/11 16:02:01 cafagna Exp $ |
3 |
* |
4 |
* $Log: npoiss.F,v $ |
5 |
* Revision 3.1.1.1 2002/07/11 16:02:01 cafagna |
6 |
* First GPAMELA release on CVS |
7 |
* |
8 |
* |
9 |
*CMZ : 3.00/00 06/04/2001 11.21.19 by Marialuigia Ambriola |
10 |
*-- Author : Marialuigia Ambriola 05/04/2001 |
11 |
INTEGER FUNCTION NPOISS(X) |
12 |
************************************** |
13 |
* Simulate the Poisson distribution |
14 |
* From data particle book vol. 15 2000 |
15 |
************************************** |
16 |
REAL U(1),A,X |
17 |
INTEGER K,N |
18 |
NPOISS=0 |
19 |
K=1 |
20 |
A=1. |
21 |
c ml26/03/04 100 U=RNDM(1) |
22 |
100 CALL GRNDM(U,1) |
23 |
A=U(1)*A |
24 |
IF(A.LT.EXP(-X)) THEN |
25 |
N=K-1 |
26 |
ELSE |
27 |
K=K+1 |
28 |
GOTO 100 |
29 |
ENDIF |
30 |
NPOISS=N |
31 |
RETURN |
32 |
END |