Comments (1)
Hi @davidjr82,
Thank you for your interest in MathPHP.
Quartiles, unfortunately, do not have a single standard way to compute them. In R for instance, there are nine different variations. Excel has two. The Wikipedia article shows four. MathPHP's documentation for quartilesInclusive
indicates it uses the "Tukey's hinges" quartile method, which is "method 2" in the Wikipedia article.
Method 2
Use the median to divide the ordered data set into two-halves.
If there are an odd number of data points in the original ordered data set, include the median (the central value in the ordered list) in both halves.
If there are an even number of data points in the original ordered data set, split this data set exactly in half.
The lower quartile value is the median of the lower half of the data. The upper quartile value is the median of the upper half of the data.
The values found by this method are also known as "Tukey's hinges";[4] see also midhinge.
Using your dataset and computing the Wikipedia method 2 by hand.
[0,900,1800,2700,3600,4500]
Use the median to divide the ordered data set into two-halves.
There is an even number of numbers, so the median is the average of 1800 and 2700 which is 2250.
If there are an even number of data points in the original ordered data set, split this data set exactly in half.
Lower half = [0, 900, 1800]
Upper half = [2700, 3600, 4500]
The lower quartile value is the median of the lower half of the data
The median of [0, 900, 1800]
is 900.
The upper quartile value is the median of the upper half of the data.
The median of [2700, 3600, 4500]
is 3600.
This matches the result MathPHP provides.
Also for reference, there are multiple quartile methods in R which give the same result:
> quantile(c(0, 900, 1800, 2700, 3600, 4500), type=2)
0% 25% 50% 75% 100%
0 900 2250 3600 4500
> quantile(c(0, 900, 1800, 2700, 3600, 4500), type=5)
0% 25% 50% 75% 100%
0 900 2250 3600 4500
Keep in mind there is also a Descriptive::percentile
function you can use which has a more "standard" definition if that is what you are looking for.
Descriptive::percentile([0,900,1800,2700,3600,4500], 25) // 1125
from math-php.
Related Issues (20)
- Dealing with NANs HOT 3
- Integer Modulo n HOT 3
- Add vector, matrix and quaternion operations for 3d geometry HOT 1
- Could math-php support KPHP? HOT 1
- Truncated Mean Percentage HOT 5
- Incompatibility with Iterator and ArrayAccess interfaces HOT 1
- MiddlePayment For Loan HOT 2
- `number` is not a valid PHP type HOT 5
- Kernel Density Estimation: Improved Sheather-Jones algorithm HOT 4
- Bug for the t-test? HOT 5
- Add row/column algebra methods to Matrix for Vector HOT 3
- Document additional Matrix Row Operations and add their Columnar counterparts HOT 5
- Implicit Behavior of ImmutableSet
- Add Moore-Penrose Inverse HOT 12
- Psalm does not understand `number` pseudo-type HOT 3
- Add a factor method for Polynomials HOT 4
- Repeated measures ANOVA HOT 1
- Question regarding Linear regression on cicular data HOT 1
- How to detect a number is prime or not using this package?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from math-php.