Click here to reset or clear this form
This tool is developed by: PHP Developer. org
Click here to proceed with the analysis');
}
else
{
//explode data and assign it to an array
$data1 = explode("\n", $firstsample);
$data2 = explode("\n", $secondsample);
////////////////////////////////
//ANALYSIS FOR 1ST DATA SETS///
///////////////////////////////
//function to compute statistical mean
function average1($data1) {
return array_sum($data1)/count($data1);
}
$dataaverage1 = average1($data1);
//function to compute standard deviation
function stdev1($data1){
$average1 = average1($data1);
foreach ($data1 as $value1) {
$variance1[] = pow($value1-$average1,2);
}
$standarddeviation1 = sqrt((array_sum($variance1))/((count($data1))-1));
return $standarddeviation1;
}
$datastandarddeviation1 = stdev1($data1);
//variance of data set 1
$datavariance1 = $datastandarddeviation1 * $datastandarddeviation1;
//number of data for 1st data set
$count1 =count($data1);
//variance over number of data
$sterror1 = $datavariance1/$count1;
////////////////////////////////
//ANALYSIS FOR 2nd DATA SETS///
///////////////////////////////
//function to compute statistical mean
function average2($data2) {
return array_sum($data2)/count($data2);
}
$dataaverage2 = average2($data2);
//function to compute standard deviation
function stdev2($data2){
$average2 = average2($data2);
foreach ($data2 as $value2) {
$variance2[] = pow($value2-$average2,2);
}
$standarddeviation2 = sqrt((array_sum($variance2))/((count($data2))-1));
return $standarddeviation2;
}
$datastandarddeviation2 = stdev2($data2);
//variance of data set 2
$datavariance2 = $datastandarddeviation2 * $datastandarddeviation2;
//number of data for 2nd data set
$count2 =count($data2);
//variance over number of data
$sterror2 = $datavariance2/$count2;
////////////////////////////
//COMPUTE STANDARD ERROR///
//////////////////////////
$sumerror=$sterror1+ $sterror2;
$standarderror=sqrt($sumerror);
///////////////////////////////////
//COMPUTE DIFFERENCE OF TWO MEANS//
///////////////////////////////////
$difference=$dataaverage1-$dataaverage2;
$meandifference=abs($difference);
////////////////////
//COMPUTE T-VALUE///
////////////////////
$tvalue=$meandifference/$standarderror;
///////////////////////////////
//COMPUTE DEGREES OF FREEDOM///
///////////////////////////////
$df=$count1 + $count2 -2;
///////////////////////////////////////////////
//EXTRACT CRITICAL T VALUE FROM THE DATABASE///
///////////////////////////////////////////////
$df = mysql_real_escape_string(stripslashes($df));
$result = mysql_query("SELECT `critical` FROM `ttest` WHERE `degrees`='$df'")
or die(mysql_error());
// store the record of the "example" table into $row
$row = mysql_fetch_array($result)
or die("Invalid query: " . mysql_error());
// Print out the contents of the entry
$criticaltvalue = $row['critical'];
//////////////////////////////////////////
//COMPARE CRITICAL AND COMPUTED T VALUE///
//////////////////////////////////////////
if ($tvalue > $criticaltvalue)
//they are statistical different
{
echo 'T-Test Results of the Analyzed Samples:
';
echo '
';
echo 'The two data sets are statistical DIFFERENT at 95% confidence level.It says that the two samples are NOT the same.
';
echo 'The computed t-value is: '.$tvalue;
echo '
';
echo 'And the critical t-value is: '.$criticaltvalue;
echo '
';
echo 'The computed degrees of freedom is: '.$df;
echo '
';
echo 'Click here to do another analysis';
}
else
//they are not statistically different
{
echo 'T-Test Results of the Analyzed Samples:
';
echo '
';
echo 'The two data sets are NOT statistical different at 95% confidence level.It says that the two samples are the same.
';
echo 'The computed t-value is: '.$tvalue;
echo '
';
echo 'And the critical t-value is: '.$criticaltvalue;
echo '
';
echo 'The computed degrees of freedom is: '.$df;
echo '
';
echo 'Click here to do another analysis';
}
echo '
';
echo 'Below is the submitted/analyzed data for your reference';
echo '
';
$display1 = implode("\n
", $data1);
$display2 = implode("\n
", $data2);
echo '';
echo '';
echo 'Data | ';
echo '
';
echo ''.$display1.' |
';
echo ''.$display2.' |
';
echo '
';
}
}
?>