function void() { } include("header.inc"); include("ga.php"); if (!isset($sim)) { ?>
} else { require("db.inc"); require("lib.inc"); $link = mysql_pconnect("localhost", $dbuser, $dbpass); mysql_select_db($dbname); $dist = ($highval - $lowval) / 2; $mean = $lowval + $dist; $gauss_step = $dist / 3.2; if($shifts!=="0") { $steps = 86400 / 60; $shift_step = round($steps / $shifts); $shift_distance = rand(1, $shift_step - 1); } $count = 0; $newmean = $mean; $in_shift = "0"; $shift_counter = 0; $ssize = $subsize; $shi = 0; $up = 1; $start_ts = mktime(0, 0, 0, 4, 4, 2008); $query = "insert into datasets (name) values ('$dataset')"; mysql_query($query); $new_id = mysql_insert_id(); $go_down = 0; $go_up = 1; for ($i=$start_ts; $i<=$start_ts+86400; $i += 60) { $count++; // CHOOSE SHIFT LOCATION if($count==$shift_distance) { $in_shift="1"; $shift_counter++; if ($shifts > $shift_counter) { $shift_distance = rand($shift_step * $shift_counter, ($shift_step * ($shift_counter+1)) - 1); if($shift_distance==$count+1) { $shift_distance++; } } } $sum = 0; $highlim = $highval - (rand(0, $dist) / rand(5, 10)); $lowlim = $lowval + (rand(0, $dist) / rand(5, 10)); $up++; if ($up==3) { $up = -1; } // GENERATE SAMPLES for($a=0; $a<$ssize; $a++) { // POSITIVE AUTOCORELLATION if($special=="poscor") { if(!isset($lastval)) { $value = $lowval + rand(0, $dist * 2); $sum = $sum + $value; } else { if($go_up==1) { $value = $lastval + (rand(0, $dist) / rand(3, 10)); if ($value>$highlim) { $value = $highlim; $go_down = 1; $go_up = 0; } $sum = $sum + $value; } else if ($go_down==1) { $value = $lastval - (rand(0, $dist) / rand(3, 10)); if ($value<$lowlim) { $value = $lowlim; $go_up = 1; $go_down = 0; } $sum = $sum + $value; } } if ($a==$ssize-1) { $lastval = $sum / $ssize; } } else if ($special=="gauss") { // GAUSS DISTRIBUTION $value = $mean + gauss() * $gauss_step; } else if ($special=="negcor") { // NEGATIVE AUTOCORELLATION if(!isset($lastval)) { $value = $lowval + rand(0, $dist * 2); $sum = $sum + $value; } else { if($go_up==1) { $value = $lastval + (rand(0, $dist) / rand(3, 10)); if ($value>$highlim) { $value = $highlim; $go_down = 1; $go_up = 0; } if ($up<1) { $tmp = $mean - $value; $value = $mean + ($value*-1); } $sum = $sum + $value; } else if ($go_down==1) { $value = $lastval - (rand(0, $dist) / rand(3, 10)); if ($value<$lowlim) { $value = $lowlim; $go_up = 1; $go_down = 0; } if ($up<1) { $tmp = $mean - $value; $value = $mean + ($value*-1); } $sum = $sum + $value; } } if ($a==$ssize-1) { $lastval = $sum / $ssize; } } else { // NORMAL DISTRIBUTION $value = $lowval + rand(0, $dist * 2); } // SHIFT INFO if($in_shift=="1") { $shi=1; $in_shift=0; } // PUT INTO DB $query = "insert into logs (moment, set_id, value, shift) values ('$i', '$new_id', '$value', '$shi')"; // printf("%f