Merge branch 'development' into feature/see
This commit is contained in:
commit
51f2726c3d
23 changed files with 424 additions and 242 deletions
|
|
@ -40,10 +40,10 @@ MODULE moduleRandom
|
|||
INTEGER:: rnd
|
||||
REAL(8):: rnd01
|
||||
|
||||
rnd = 0.D0
|
||||
rnd = 0
|
||||
CALL RANDOM_NUMBER(rnd01)
|
||||
|
||||
rnd = INT(REAL(b - a) * rnd01) + 1
|
||||
rnd = a + FLOOR((b+1-a)*rnd01)
|
||||
|
||||
END FUNCTION randomIntAB
|
||||
|
||||
|
|
@ -91,10 +91,21 @@ MODULE moduleRandom
|
|||
REAL(8), INTENT(in):: cumWeight(1:)
|
||||
REAL(8), INTENT(in):: sumWeight
|
||||
REAL(8):: rnd0b
|
||||
INTEGER:: rnd
|
||||
INTEGER:: rnd, i
|
||||
|
||||
rnd0b = random(0.D0, sumWeight)
|
||||
rnd = MINLOC(DABS(rnd0b - cumWeight), 1)
|
||||
rnd0b = random()
|
||||
i = 1
|
||||
DO
|
||||
IF (rnd0b <= cumWeight(i)/sumWeight) THEN
|
||||
rnd = i
|
||||
EXIT
|
||||
|
||||
ELSE
|
||||
i = i +1
|
||||
|
||||
END IF
|
||||
END DO
|
||||
! rnd = MINLOC(DABS(rnd0b - cumWeight), 1)
|
||||
|
||||
END FUNCTION randomWeighted
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue