Random number generator with normal distribution
Registered by
Michael-Olaf
Implementation of a random number generator with normal distribution. Input paramters are: minimum and maximum.
Blueprint information
- Status:
- Started
- Approver:
- Michael-Olaf
- Priority:
- Medium
- Drafter:
- Michael-Olaf
- Direction:
- Approved
- Assignee:
- Michael-Olaf
- Definition:
- Approved
- Series goal:
- Accepted for trunk
- Implementation:
- Started
- Milestone target:
- 2.0
- Started by
- Michael-Olaf
- Completed by
Whiteboard
Code for a normal distribution:
private static function gauss($min,$max){
$x1 = 0;
$x2 = 0;
$w = 0;
$y1 = 0;
$y2 = 0;
$deviation = ($max-$min)/6;
$median = ($max+$min)/2;
do {
$x1 = 2.0 * (rand()
$x2 = 2.0 * (rand()
$w = $x1 * $x1 + $x2 * $x2;
} while ( $w >= 1.0 );
$w = sqrt( (-2.0 * log( $w ) ) / $w );
$y1 = $x1*$w;
$y1 *= $deviation;
$y1 += $median;
return $y1;
}
(?)
Work Items
Dependency tree
* Blueprints in grey have been implemented.