<?php
class data
{
var $mean;
var $averagePeriod;
var $squarePeriod;
var $percentError;
var $percentErrorSquare;
var $totalError;
var $actualError;
var $centroidX;
var $centroidY;
var $actualRulerError;
function getActualError()
{
$absolute = ($this->percentErrorSquare / 100);
$this->actualError = $this->squarePeriod * $absolute;
$this->actualError = round($this->actualError, 3);
}
function getActualRulerError()
{
$this->actualRulerError = $this->getTotalError(2);
$this->actualRulerError = ($this->actualRulerError);
}
function getPercentError($i)
{
$percentError = (($this->getTotalError($i) / $this->mean) * 100);
$this->percentError = round($percentError, 2);
$this->percentErrorSquare = round((2 * $this->percentError) , 2);
}
function getTotalError($i)
{
$cal1 = $_SESSION['cal' . $i];
$read1 = $_SESSION['read' . $i];
$random1 = $_SESSION['random' . $i];
$max = $cal1;
if ($read1 > $max)
{
$max = $read1;
}
if ($random1 > $max)
{
$max = $random1;
}
$count = 0;
$findDominant = $max / 3;
if ($cal1 <= $findDominant)
{
$count += 1;
}
if ($read1 <= $findDominant)
{
$count += 1;
}
if ($random1 <= $findDominant)
{
$count += 1;
}
if ($count == 2)
{
$this->totalError = $max;
return $this->totalError;
}
else
{
$total = pow($cal1, 2) + pow($read1, 2) + pow($random1, 2);
$this->totalError = sqrt($total);
return $this->totalError;
}
}
function getAveragePeriod()
{
$this->averagePeriod = ($this->mean / 10);
}
function getSquarePeriod()
{
$this->squarePeriod = pow($this->averagePeriod, 2);
$this->squarePeriod = round($this->squarePeriod, 3);
}
function getMean($values)
{
$values = explode(",", $values);
$numValues = count($values);
$value = 0;
foreach ($values as $value)
{
$total += $value;
}
$this->mean = round(($total / $numValues), 2);
return $this->mean;
}
function centroidX($numRuns)
{
$i = 1;
$total = 0;
$minus = 0;
while ($i <= $numRuns)
{
$total += $_SESSION['startLength'] - $minus;
$minus += $_SESSION['increments'];
$i++;
}
$total = $total / ($numRuns + 1);
$this->centroidX = $total;
}
}
?>