Generating Random Numbers

Hello…I’m totally new to PHP and making lots of mistakes but I’m trying my best…I got this code to run in my generator but it won’t produce any numbers at all…just a blank page…am I missing something in my code??? I even tried several different ways as you can tell but still no numbers output…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]
Sponsor our Newsletter | Privacy Policy | Terms of Service