Simple linear regression implemented with PHP: (i) _php tutorial

Source: Internet
Author: User
The importance of database in PHP
There is a lack of a powerful tool in the PHP field: a language-based math library. In this two-part series, Paul Meagher wants to inspire PHP developers to develop and implement a PHP-based math library by providing an example of how to develop an analytics model library. In the 1th part, he demonstrates how to use PHP as an implementation language to develop and implement the core part of the simple linear regression (Linear Regression) algorithm package. In part 2nd, the author adds functionality to the package: useful data analysis tools for small and medium sized datasets.
Brief introduction
Compared to other open source languages such as Perl and Python, the PHP community lacks a strong job to develop a math library.
One reason for this may be that there are already a large number of sophisticated mathematical tools, which may hinder the community's own efforts to develop PHP tools. For example, I have studied a powerful tool, S System, which has an impressive set of statistical libraries designed to analyze datasets and was awarded the ACM Award for its language design in 1998. If S or its open source similar R is just a Exec_shell call, then why bother to use PHP to achieve the same statistical computing function? For more information about the S System, its ACM award, or R, see Resources.
Isn't this a waste of developer energy? If the motivation to develop a PHP math library is to save developers ' energy and use the best tools to get the job done, PHP's current topic is meaningful.
On the other hand, the development of the PHP Math library may be encouraged for instructional reasons. For about 10% of people, Mathematics is an interesting topic to explore. For those who are also skilled at using PHP, the development of the PHP Math library can enhance the learning process of mathematics, in other words, do not just read the section on T tests, but also implement a class that can calculate the corresponding intermediate values and display them in a standard format.
Through coaching and training, I want to prove that developing a PHP math library is not a difficult task, it may represent an interesting technical and learning challenge. In this article, I'll provide an example of a PHP math library called Simplelinearregression, which demonstrates a common approach that you can use to develop a PHP math library. Let's start by discussing some common principles that guide me in developing 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 the reverse link to develop the class.
3. A large number of getter is expected.
4. Store intermediate results.
5. Make a preference for the detailed API.
6. Perfection is not a goal.
7. Let us examine these guidelines 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 procedure name, which contains the input function, the function that calculates the median and the total value, and the output function (which displays the median and total values in text or graphic format all on the screen).

http://www.bkjia.com/PHPjc/631761.html www.bkjia.com true http://www.bkjia.com/PHPjc/631761.html techarticle The importance of database in PHP the PHP domain lacks a powerful tool: a language-based math library. In this two-part series of articles, Paul Meagher hopes to pass ...

  • 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.