Download the PHP package dwo/math without Composer
On this page you can find all versions of the php package dwo/math. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package math
Short Description Library to deal with some mathematical stuff. Implemented or partially implemented mathematical concepts are: Complex number, Matrix, Normal distribution, Random, Angle, Random Complex, Descriptive Statistics, Parametric tests (Anova, Dependant t-Test) and Non-Parametric tests (Wilcoxon Signed-rank test, Wilcoxon-Mann-Whitney test, Kruskal-Wallis).
License MIT
Homepage https://github.com/malenkiki/math
Informations about the package math
Math
Library to deal with some mathematical stuff.
Implemented or partially implemented mathematical concepts are: Complex number, Matrix, Normal distribution, Random, Angle, Random Complex, Descriptive Statistics, Parametric tests (Anova, Dependant t-Test) and Non-Parametric tests (Wilcoxon Signed-rank test, Wilcoxon-Mann-Whitney test, Kruskal-Wallis).
Install
You can get this lib by downloading the ZIP archive, cloning this repository or using Composer with the following code to put into your composer.json
file:
Angle
You can use angles as deg, gon, rad or turn. By default, radians is used.
You can get DMS style too:
You can test whether current angle is right, straight or perigon:
You can test current angle with another to know is they are complementary or supplementary:
Matrix
Creating matrix is simple, first step, you instanciate it with column numbers and row numbers, second step, you put data into it.
Getting data is not difficult too. You can get matrice’s size, content for a row or a column, all data and even a dump as a string.
Getting matrix transpose is as simple as that:
OK, you can get, you can set… but you can do more complicated things.
You can multiply matrix with another one, but beware of compatibility!
You can multiply matrix with a scalar too, or a complex number:
Addition is possible too, you must test before if size of each matrix is the same, or catch exception.
Getting determinant of a square matrix is easy, just do the following:
If you try to get determinant for a non square matrix, you get an Exception.
Inverse of square matrix is simple too, and like you can imagine, it is like that:
The cofactor matrix, used be previous method, is compute with that:
Complex
Using complex is like a child game: instanciate it with real part and imaginary part. That’s all!
But you can create complex number using rho and theta values, theta can be simple float or Angle object:
Complex number object acts like string too, remembering its original form:
You have some magic getters:
You can do addition, multiplication:
Get negative and conjugate is simple too:
Normal distribution
You can play with graph for given mean and standard deviation, or you can generate fake samples.
Some examples to understand:
Factorial
You can get factorial of one integer, it is very easy to use, instanciate it with n
rank and then get value by calling result
attribute.
String context is available too:
Random
You can play with random numbers, included into integer range or as float between 0 and 1.
You can take one:
You can take many:
You can take many without replacement:
Random Complex Number
This class allows you to get one or many complex numbers with real and imaginary or rho and theta inside given range.
So, to get one complex number with its real part into [2, 6.5]
range and
its imaginary part into [-2, 5]
range, you must do that:
You can do that with trigonometric form too, but now with 10 generated items:
Descriptive Statistics
You can do a lot of stats about data, like mean, variance, standard deviation, kurtosis, etc.
You can put all values at once while instanciating:
You can add others data after too:
Counting values is as easy to use count()
:
Many means are avaialble too:
Variance, population or sample are available with standard deviation too:
Quartiles and median:
Getting mode(s):
Frequencies, relative frequencies and cumulative frequencies:
Kurtosis and its tests are available:
Parametric Tests
Anova
One example is better than long blahblah:
Dependant t-Test
Non Parametric Tests
Wilcoxon Signed-Ranks Test
TODO
Dev in progress, more informations soon here on into source code!
MIT Open Source License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.