The importance of the Linux script development math library in PHP

Source: Internet
Author: User
Tags php class

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 is that there are already a large number of sophisticated mathematical tools that may be preventing the community from developing its own PHP tools. For example, I have studied a powerful tool S System, which has an impressive set of statistical databases, designed to analyze datasets, and was awarded the ACM Award in 1998 for its language design. If S or its open source category R is just a exec_shell call, why bother using PHP to achieve the same statistical computing function? For more information on S System, its ACM awards, or R, see Resources.

Isn't this a waste of developer energy? If the motivation for developing a PHP math library is to save the developer's energy and use the best tools to do the job, then PHP's current topic is meaningful.

On the other hand, motivation for teaching may encourage the development of a PHP math library. For about 10% of the people, mathematics is an interesting subject to explore. For those who are also skilled at PHP, the development of the PHP Math library can enhance the math learning process, in other words, not just reading chapters on T-tests, but also implementing a class that calculates the intermediate values and displays 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 technology and learning problem. In this article, I'll provide a sample PHP math library, called Simplelinearregression, which demonstrates a common way 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 simplelinearregression classes.

Each analysis model builds a class.

Use reverse links to develop classes.

Expected to have a large number of getter.

Store intermediate results.

Develop preferences for detailed APIs.

Perfection is not a goal.

Let's look at these guidelines in more detail.

Each analysis model builds a class

Each major analytical test or procedure should have a PHP class with the same name as the test or procedure name, which contains the input functions, functions and output functions that calculate the intermediate value and the total value (the median and total values are displayed on the screen in text or graphic format).

Use reverse link to develop class

In mathematical programming, the goal of encoding is usually the standard output value that an analysis process (such as multipleregression, TimeSeries, or chisquared) expects to generate. From a problem-solving perspective, this means that you can use reverse linking to develop a method of mathematical classes.

For example, the summary Output screen displays one or more summary statistics. These summary statistical results depend on the calculation of the intermediate statistic results, which may involve a deeper level of intermediate statistics, and so on. This development method based on the reverse link derives the next principle.

Expected to have a large number of getter

Most of the math class development work involves calculating intermediate values and summary values. In fact, this means that you should not be surprised if your class contains many getter methods for calculating intermediate and aggregate values.

Store intermediate Results

The intermediate results are stored in the result object so that you can use the intermediate result as input for subsequent computations. This principle is implemented in S language design. In the current environment, this principle is implemented by selecting the instance variable to represent the calculated intermediate value and the aggregated result.

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.