Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Five-number summary
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Example== This example calculates the five-number summary for the following set of observations: 0, 0, 1, 2, 63, 61, 27, 13. These are the number of moons of each planet in the [[Solar System]]. It helps to put the observations in ascending order: 0, 0, 1, 2, 13, 27, 61, 63. There are eight observations, so the median is the mean of the two middle numbers, (2 + 13)/2 = 7.5. Splitting the observations either side of the median gives two groups of four observations. The median of the first group is the lower or first quartile, and is equal to (0 + 1)/2 = 0.5. The median of the second group is the upper or third quartile, and is equal to (27 + 61)/2 = 44. The smallest and largest observations are 0 and 63. So the five-number summary would be 0, 0.5, 7.5, 44, 63. ===Example in R=== It is possible to calculate the five-number summary in the [[R programming language]] using the <code>fivenum</code> function. The <code>summary</code> function, when applied to a vector, displays the five-number summary together with the mean (which is not itself a part of the five-number summary). The <code>fivenum</code> uses a different method to calculate percentiles than the <code>summary</code> function. {{sxhl|2=rout| > moons <- c(0, 0, 1, 2, 63, 61, 27, 13) > fivenum(moons) [1] 0.0 0.5 7.5 44.0 63.0 > summary(moons) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.00 0.75 7.50 20.88 35.50 63.00 }} ===Example in Python=== This python example uses the <code>percentile</code> function from the numerical library <code>numpy</code> and works in Python 2 and 3. <syntaxhighlight lang="numpy"> import numpy as np def fivenum(data): """Five-number summary.""" return np.percentile(data, [0, 25, 50, 75, 100], method="midpoint") </syntaxhighlight> <syntaxhighlight lang="pycon"> >>> moons = [0, 0, 1, 2, 63, 61, 27, 13] >>> print(fivenum(moons)) [ 0. 0.5 7.5 44. 63. ] </syntaxhighlight> === Example in SAS === You can use <code>PROC UNIVARIATE</code> in [[SAS (software)|SAS]] to get the five number summary: <syntaxhighlight lang="sas"> data fivenum; input x @@; datalines; 1 2 3 4 20 202 392 4 38 20 ; run; ods select Quantiles; proc univariate data = fivenum; output out = fivenums min = min Q1 = Q1 Q2 = median Q3 = Q3 max = max; run; proc print data = fivenums; run; </syntaxhighlight> === Example in Stata === [[File:Five number summary.png|thumb|336px|A five number summary of a distribution of data.]] <syntaxhighlight lang="stata"> input byte y 0 0 1 2 63 61 27 13 end list tabstat y, statistics (min q max) </syntaxhighlight>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Five-number summary
(section)
Add topic