quantile!
quantile!(v, p)
Like quantile
, but overwrites the input vector.
Examples
-
Calculate the median of a vector:
julia> v = [1, 4, 3, 7, 2, 9]; julia> quantile!(v, 0.5) 6-element Array{Int64,1}: 1 2 3 4 7 9
This example calculates the median of the vector
v
using thequantile!
function. -
Determine quartiles of a dataset:
julia> data = [12, 45, 67, 23, 9, 34, 56, 78, 90, 1]; julia> quantile!(data, [0.25, 0.5, 0.75]) 10-element Array{Int64,1}: 12 34 56 23 9 12 45 67 78 90
Here, the
quantile!
function is used to calculate the quartiles (25th, 50th, and 75th percentiles) of thedata
vector. - Calculate deciles of a dataset:
julia> numbers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]; julia> quantile!(numbers, [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]) 10-element Array{Int64,1}: 5 10 15 20 25 30 35 40 45 50
This example demonstrates how to calculate deciles (10th, 20th, 30th, ..., 90th percentiles) of the
numbers
vector usingquantile!
.
Common mistake example:
julia> arr = [5, 10, 15, 20];
julia> quantile!(arr, 1.5)
ERROR: ArgumentError: `p` must be a scalar or a vector of percentiles in the range [0,1].
In this example, the p
argument provided is out of range. The p
argument should be a scalar or a vector of percentiles between 0 and 1. Make sure to pass valid values to the quantile!
function to avoid such errors.
See Also
cummax, eigmax, findmax, hist, hist!, hist2d, hist2d!, histrange, indmax, maxabs, maxabs!, maximum!, mean, mean!, median, median!, minabs, minabs!, minimum!, minmax, quantile!, realmax, std, stdm,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.