HomePHP Page 3 - Performing Inferential Statistical Analysis with PHP
Programming Strategy in PHP - PHP
Statistics aren't just for Excel spreadsheets anymore. If you've been wondering how to use PHP to help you do a basic statistical analysis, keep reading. In this article you'll learn how to use PHP to help you compare data sets.
It can be difficult to implement the above concepts in the programming. This is why you'll find very few PHP developers online who are willing to develop this kind of application.
Anyway, with the solid background provided above, we can start with a web form that accepts two data sets. It should be two text areas, to make it easy for users to enter data (using the copy-and-paste method instead of entering data one small piece at a time, which can be very stressful to use).
The script should then accept the numerical data and start computing the descriptive statistics (average, standard deviation, degrees of freedom). With these variables computed, we can compute the T value.
So how will the T-critical value be computed? The best method is to obtain t-critical value from MS Excel, save it as .csv, and then export it to the MySQL database. To follow the industry standard, we can fix those tables to use the 95% confidence level.
In Excel, the T-critical value can be computed using the Excel function called TINV (%error, degrees of freedom), so for a 95% level, % error is 5% (0.05). In an Excel spreadsheet, a table can be generated using this formula, like the one shown below:
Complete the tables as shown above (you can have more than 100 “degrees of freedom” to make sure your applications can accept high amount of samples).
Once the t-critical value is in place at the MySQL database, we can query it based on degrees of freedom and use PHP to compare it with the T value computed (above).