php开发数学课件,Numbers PHP:一个高级的PHP的数学工具包

Numbers.php

Numbers.php - an advanced mathematics toolkit for PHP >= 5.3. It is a port of Numbers.js - same toolkit for JavaScript.

Description

Numbers.php provides a comprehensive set of mathematical tools that currently are not offered in PHP. These tools include:

Basic calculations

Calculus

Matrix Operations

Prime Numbers

Statistics

More...

A few things to note before using: PHP, like many languages, does not necessarily manage floating points as well as we'd all like it to. For example, if adding decimals, the addition tool won't return the exact value. This is an unfortunate error. Precautions have been made to account for this. After including numbers, you can set an error bound. Anything in this will be considered an "acceptable outcome."

The primary uses cases are calculations and data analysis on the server side. For client side operations, please use Numbers.js.

How to use

Numbers is pretty straightforward to use.

For example, if we wanted to estimate the integral of sin(x) from -2 to 4, we could:

Use riemann integrals (with 200 subdivisions)

use NumbersPHP\Calculus;

use NumbersPHP\Matrix;

use NumbersPHP\Statistic;

use NumbersPHP\Prime;

Calculus::riemann('sin', -2, 4, 200);

Or use adaptive simpson quadrature (with epsilon 0.0001)

Calculus::adaptiveSimpson('sin', -2, 4, 0.0001);

User-defined functions can be used too:

function myFunc($x) {

return 2 * pow($x, 2) + 1;

}

Calculus::riemann('myFunc', -2, 4, 200);

Calculus::adaptiveSimpson(create_function('$x', 'return 2 * pow($x, 2) + 1;'), -2, 4, 0.0001);

Now say we wanted to run some matrix calculations:

We can add two matrices

$matrix1 = array(array(0, 1, 2),

array(3, 4, 5));

$matrix2 = array(array( 6, 7, 8),

array( 9, 10, 11));

Matrix::addition($matrix1, $matrix2);

We can transpose a matrix

Matrix::transpose($array);

Numbers also includes some basic prime number analysis. We can check if a number is prime:

//basic check

Prime::simple($number);

// Miller�Rabin primality test

Prime::millerRabin($number);

The statistics tools include mean, median, mode, standard deviation, random sample generator, correlation, confidence intervals, t-test, chi-square, and more.

Statistic::mean($array);

Statistic::median($array);

Statistic::mode($array);

Statistic::standardDev($array);

Statistic::randomSample($lower, $upper, $n);

Statistic::correlation($array1, $array2);

Test

Download and install these things:

Run in the command prompt:

php composer.phar install

php phpunit.phar --configuration phpunit.xml.dist

If you are going to run tests multiple times and you are using Microsoft(R) Windows(TM), you can use the batch file /test.cmd. Do not forget to set the path to PHP, Composer, and PHPUnit in the beginnig of that file.

Authors

Numbers.js

Steve Kaliski - sjkaliski

David Byrd - davidbyrd11

Ethan Resnick - studip101

Hrishikesh Paranjape - hrishikeshparanjape

Greg Leppert - leppert

Lars-Magnus Skog - ralphtheninja

Miles McCrocklin - milroc

Nate Kohari - nkohari

Eric LaForce - elaforc

Kartik Talwar - KartikTalwar

swair shah - swairshah

Jason Hutchinson - Zikes

Philip I. Thomas - philipithomas

Brandon Benvie - Benvie

Larry Battle - LarryBattle

Numbers.php

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值