Hello…This code runs but it just won’t generate ANY random numbers at all…I tried all different ways as you can see but none of them will generate the numbers as needed…any help please…
[php]<?php
//include ("gause.php");
// this lets the processor know that this data type relies on data defined in other fields. That
// information is either hardcoded in the functions below, or passed via an option
$NormalDistribution_process_order = 1;
function NormalDistribution_get_template_options($postdata, $col, $num_col){
if (!isset($postdata["NormalDistributionMu_$col"]) || empty($postdata["NormalDistributionMu_$col"]) ||
!isset($postdata["NormalDistributionSigma_$col"]) || empty($postdata["NormalDistributionSigma_$col"])) {
return false;
}
$gauss = gauss();
$this->randMax = (float) getrandmax();
return array(
"mu" => $postdata["NormalDistributionMu_$col"],
"sigma" => $postdata["NormalDistributionSigma_$col"]
);
}
function NormalDistribution_generate_item($row, $options, $existing_row_data)
{
function gauss()
{ // N(0,1)
// returns random number with normal distribution:
// mean=0
// std dev=1
// auxilary vars
$x=random_0_1();
$y=random_0_1();
// two independent variables with normal distribution N(0,1)
$u=sqrt(-2log($x))cos(2pi()$y);
$v=sqrt(-2log($x))sin(2pi()$y);
// i will return only one, couse only one needed
return $u;
}
function gauss_ms($mu=0.0,$sigma=1.0)
{ //N(m,s)
// returns random number with normal distribution:
//mean=m
//std dev=s
//return gauss()*$sigma+$mu;
return $this->gauss() * $sigma + $mu;
}
function random_0_1()
{ // auxiliary function
// returns random number with flat distribution from 0 to 1
return (float)rand()/(float)getrandmax();
//return rand($options[“min”], $options[“max”]);
}
function NormalDistribution_get_export_type_info($export_type, $options)
{
$info = "";
switch ($export_type)
{
case "sql":
if ($options == "MySQL" || $options == "SQLite")
$info = "mediumint default NULL";
else if ($options == "Oracle")
$info = "varchar2(50) default NULL";
break;
}
return $info;
}
}[/php]