Simple linear regression implemented using PHP: (1) _ PHP Tutorial

Source: Internet
Author: User
Simple linear regression implemented using PHP: (1 ). The importance of databases in PHP The PHP field lacks a powerful tool: a language-based mathematical library. In this two-part series, PaulMeagher wants to use the importance of databases in PHP
PHP lacks a powerful tool: a language-based mathematical library. In this two-part series, Paul Meagher hopes to inspire PHP developers to develop and implement a PHP-based mathematical library by providing an example of how to develop and analyze the model Library. In section 1st, he demonstrated how to use PHP as the implementation language to develop and implement the core part of the Simple Linear Regression algorithm package. In Part 1, the author adds some features in this package: a useful data analysis tool for small and medium sized datasets.
Introduction
Compared with other open-source languages (such as Perl and Python), the PHP community lacks powerful work to develop a math library.
One reason for this situation may be that there are already a large number of mature mathematical tools, which may hinder the community's self-development of PHP Tools. For example, I have studied a powerful tool, S System, which has an impressive set of statistical libraries specially designed to analyze datasets, in 1998, the ACM Award was awarded for its language design. If S or its open source code similar R is just an exec_shell call, why bother using PHP to implement the same statistical computing function? For more information about S System, its ACM Award, or R, see references.
Isn't that a waste of developer energy? If the motivation for developing a PHP math library is to save developers' energy and use the best tools to complete the work, the current topic of PHP is very meaningful.
On the other hand, the development of PHP math libraries may be encouraged out of teaching motivation. For about 10% of people, mathematics is an interesting topic worth exploring. For those who are still familiar with PHP, the development of the PHP math library can enhance the math learning process. In other words, do not just read the section on T testing, you also need to implement a class that can calculate the corresponding median and display them in the standard format.
Through guidance and training, I hope to prove that developing a PHP math library is not a very difficult task. it may represent an interesting technology and learning challenge. In this article, I will provide a PHP math library example named SimpleLinearRegression, which demonstrates a common method for developing the PHP math library. Let's start with discussing some general principles that guide me to develop this SimpleLinearRegression class.
Guiding principles
I used six general principles to guide the development of the SimpleLinearRegression class.
1. create a class for each analysis model.
2. use reverse links for development.
3. a large number of getters are expected.
4. store intermediate results.
5. develop preferences for detailed APIs.
6. perfection is not a goal.
7. let us study these guidelines one by one in more detail.
Create a class for each analysis model
Each major analysis test or process should have a PHP class with the same name as the test or process, this class contains the input function, the function for calculating the median and aggregate value, and the output function (display the median and aggregate value in text or graphic format on the screen ).

The importance of PHP in PHP lacks a powerful tool: a language-based mathematical library. In this two-part series, Paul Meagher hopes...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.