NaNStatistics
Documentation for the NaNStatistics.jl package.
NaNStatistics.countnans
NaNStatistics.countnotnans
NaNStatistics.histcountindices
NaNStatistics.histcountindices!
NaNStatistics.histcounts
NaNStatistics.histcounts
NaNStatistics.histcounts!
NaNStatistics.histcounts!
NaNStatistics.inpctile
NaNStatistics.movmean
NaNStatistics.nanaad
NaNStatistics.nanadd
NaNStatistics.nanadd!
NaNStatistics.nanargmax
NaNStatistics.nanargmin
NaNStatistics.nanbinmean
NaNStatistics.nanbinmean
NaNStatistics.nanbinmean
NaNStatistics.nanbinmean!
NaNStatistics.nanbinmean!
NaNStatistics.nanbinmedian
NaNStatistics.nanbinmedian!
NaNStatistics.nancor
NaNStatistics.nancor
NaNStatistics.nancov
NaNStatistics.nancov
NaNStatistics.nancumsum
NaNStatistics.nanextrema
NaNStatistics.nanmad
NaNStatistics.nanmad!
NaNStatistics.nanmask
NaNStatistics.nanmask!
NaNStatistics.nanmax
NaNStatistics.nanmaximum
NaNStatistics.nanmean
NaNStatistics.nanmean
NaNStatistics.nanmedian
NaNStatistics.nanmedian!
NaNStatistics.nanmin
NaNStatistics.nanminimum
NaNStatistics.nanpctile
NaNStatistics.nanpctile!
NaNStatistics.nanquantile
NaNStatistics.nanquantile!
NaNStatistics.nanrange
NaNStatistics.nanstandardize
NaNStatistics.nanstandardize!
NaNStatistics.nanstd
NaNStatistics.nanstd
NaNStatistics.nansum
NaNStatistics.nanvar
NaNStatistics.zeronan!
NaNStatistics.countnans
— Methodcountnans(A)
Return the number of elements of A
that are NaN
s.
NaNStatistics.countnotnans
— Methodcountnonnans(A)
Return the number of elements of A
that are not NaN
s.
NaNStatistics.histcountindices!
— Methodhistcountindices!(N, bin, x, xedges::AbstractRange)
Simple 1D histogram; as histcounts!
, but also recording the bin index of each x
value.
NaNStatistics.histcountindices
— Methodhistcountindices(x, xedges::AbstractRange; T=Int64)::Vector{T}
A 1D histogram, ignoring NaN
s; as histcounts
but also returning a vector of the bin index of each x
value.
Examples
julia> b = 10 * rand(100000);
+Home · NaNStatistics.jl NaNStatistics
Documentation for the NaNStatistics.jl package.
NaNStatistics.countnans
NaNStatistics.countnotnans
NaNStatistics.histcountindices
NaNStatistics.histcountindices!
NaNStatistics.histcounts
NaNStatistics.histcounts
NaNStatistics.histcounts!
NaNStatistics.histcounts!
NaNStatistics.inpctile
NaNStatistics.movmean
NaNStatistics.nanaad
NaNStatistics.nanadd
NaNStatistics.nanadd!
NaNStatistics.nanargmax
NaNStatistics.nanargmin
NaNStatistics.nanbinmean
NaNStatistics.nanbinmean
NaNStatistics.nanbinmean
NaNStatistics.nanbinmean!
NaNStatistics.nanbinmean!
NaNStatistics.nanbinmedian
NaNStatistics.nanbinmedian!
NaNStatistics.nancor
NaNStatistics.nancor
NaNStatistics.nancov
NaNStatistics.nancov
NaNStatistics.nancumsum
NaNStatistics.nanextrema
NaNStatistics.nanmad
NaNStatistics.nanmad!
NaNStatistics.nanmask
NaNStatistics.nanmask!
NaNStatistics.nanmax
NaNStatistics.nanmaximum
NaNStatistics.nanmean
NaNStatistics.nanmean
NaNStatistics.nanmedian
NaNStatistics.nanmedian!
NaNStatistics.nanmin
NaNStatistics.nanminimum
NaNStatistics.nanpctile
NaNStatistics.nanpctile!
NaNStatistics.nanquantile
NaNStatistics.nanquantile!
NaNStatistics.nanrange
NaNStatistics.nansem
NaNStatistics.nanstandardize
NaNStatistics.nanstandardize!
NaNStatistics.nanstd
NaNStatistics.nanstd
NaNStatistics.nansum
NaNStatistics.nanvar
NaNStatistics.zeronan!
NaNStatistics.countnans
— Methodcountnans(A)
Return the number of elements of A
that are NaN
s.
sourceNaNStatistics.countnotnans
— Methodcountnonnans(A)
Return the number of elements of A
that are not NaN
s.
sourceNaNStatistics.histcountindices!
— Methodhistcountindices!(N, bin, x, xedges::AbstractRange)
Simple 1D histogram; as histcounts!
, but also recording the bin index of each x
value.
sourceNaNStatistics.histcountindices
— Methodhistcountindices(x, xedges::AbstractRange; T=Int64)::Vector{T}
A 1D histogram, ignoring NaN
s; as histcounts
but also returning a vector of the bin index of each x
value.
Examples
julia> b = 10 * rand(100000);
julia> N, bin = histcountindices(b, 0:2:10)
-([20082, 19971, 20049, 19908, 19990], [2, 3, 2, 2, 4, 2, 3, 3, 2, 4 … 1, 3, 3, 3, 3, 5, 2, 3, 3, 1])
sourceNaNStatistics.histcounts!
— Methodhistcounts!(N, x, xedges::AbstractRange)
Simple 1D histogram; as histcounts
, but in-place, adding counts to the first length(xedges)-1
elements of Array N
.
Note that counts will be added to N
, not overwrite N
, allowing you to produce cumulative histograms. However, this means you will have to initialize N
with zeros before first use.
sourceNaNStatistics.histcounts!
— Methodhistcounts!(N, x, y, xedges::AbstractRange, yedges::AbstractRange)
Simple 2D histogram; as histcounts
, but in-place, adding counts to the first length(xedges)-1
columns and the first length(yedges)-1
rows of N
elements of Array N
.
Note that counts will be added to N
, not overwrite N
, allowing you to produce cumulative histograms. However, this means you will have to initialize N
with zeros before first use.
sourceNaNStatistics.histcounts
— Methodhistcounts(x, xedges::AbstractRange; T=Int64)::Vector{T}
A 1D histogram, ignoring NaN
s: calculate the number of x
values that fall into each of length(xedges)-1
equally spaced bins along the x
axis with bin edges specified by xedges
.
By default, the counts are returned as Int64
s, though this can be changed by specifying an output type with the optional keyword argument T
.
Examples
julia> b = 10 * rand(100000);
+([20082, 19971, 20049, 19908, 19990], [2, 3, 2, 2, 4, 2, 3, 3, 2, 4 … 1, 3, 3, 3, 3, 5, 2, 3, 3, 1])
sourceNaNStatistics.histcounts!
— Methodhistcounts!(N, x, xedges::AbstractRange)
Simple 1D histogram; as histcounts
, but in-place, adding counts to the first length(xedges)-1
elements of Array N
.
Note that counts will be added to N
, not overwrite N
, allowing you to produce cumulative histograms. However, this means you will have to initialize N
with zeros before first use.
sourceNaNStatistics.histcounts!
— Methodhistcounts!(N, x, y, xedges::AbstractRange, yedges::AbstractRange)
Simple 2D histogram; as histcounts
, but in-place, adding counts to the first length(xedges)-1
columns and the first length(yedges)-1
rows of N
elements of Array N
.
Note that counts will be added to N
, not overwrite N
, allowing you to produce cumulative histograms. However, this means you will have to initialize N
with zeros before first use.
sourceNaNStatistics.histcounts
— Methodhistcounts(x, xedges::AbstractRange; T=Int64)::Vector{T}
A 1D histogram, ignoring NaN
s: calculate the number of x
values that fall into each of length(xedges)-1
equally spaced bins along the x
axis with bin edges specified by xedges
.
By default, the counts are returned as Int64
s, though this can be changed by specifying an output type with the optional keyword argument T
.
Examples
julia> b = 10 * rand(100000);
julia> histcounts(b, 0:1:10)
10-element Vector{Int64}:
@@ -15,7 +15,7 @@
10250
10039
9950
- 10033
sourceNaNStatistics.histcounts
— Methodhistcounts(x, y, xedges::AbstractRange, yedges::AbstractRange; T=Int64)::Matrix{T}
A 2D histogram, ignoring NaN
s: calculate the number of x, y
pairs that fall into each square of a 2D grid of equally-spaced square bins with edges specified by xedges
and yedges
.
The resulting matrix N
of counts is oriented with the lowest x and y bins in N[1,1]
, where the first (vertical / row) dimension of N
corresponds to the y axis (with size(N,1) == length(yedges)-1
) and the second (horizontal / column) dimension of N
corresponds to the x axis (with size(N,2) == length(xedges)-1
).
By default, the counts are returned as Int64
s, though this can be changed by specifying an output type with the optional keyword argument T
.
Examples
julia> x = y = 0.5:9.5;
+ 10033
sourceNaNStatistics.histcounts
— Methodhistcounts(x, y, xedges::AbstractRange, yedges::AbstractRange; T=Int64)::Matrix{T}
A 2D histogram, ignoring NaN
s: calculate the number of x, y
pairs that fall into each square of a 2D grid of equally-spaced square bins with edges specified by xedges
and yedges
.
The resulting matrix N
of counts is oriented with the lowest x and y bins in N[1,1]
, where the first (vertical / row) dimension of N
corresponds to the y axis (with size(N,1) == length(yedges)-1
) and the second (horizontal / column) dimension of N
corresponds to the x axis (with size(N,2) == length(xedges)-1
).
By default, the counts are returned as Int64
s, though this can be changed by specifying an output type with the optional keyword argument T
.
Examples
julia> x = y = 0.5:9.5;
julia> xedges = yedges = 0:10;
@@ -30,7 +30,7 @@
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0
- 0 0 0 0 0 0 0 0 0 1
sourceNaNStatistics.inpctile
— Methodinpctile(A, p::Number; dims)
Return a boolean array that identifies which values of the iterable collection A
fall within the central p
th percentile, optionally along a dimension specified by dims
.
A valid percentile value must satisfy 0 <= p <= 100
.
sourceNaNStatistics.movmean
— Methodmovmean(x::AbstractVecOrMat, n::Number)
Simple moving average of x
in 1 or 2 dimensions, spanning n
bins (or n*n in 2D), returning an array of the same size as x
.
For the resulting moving average to be symmetric, n
must be an odd integer; if n
is not an odd integer, the first odd integer greater than n
will be used instead.
sourceNaNStatistics.nanaad
— Methodnanaad(A; dims)
Mean (average) absolute deviation from the mean, ignoring NaN
s, of an indexable collection A
, optionally along a dimension specified by dims
. Note that for a Normal distribution, sigma = 1.253 * AAD.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanadd!
— Methodnanadd!(A, B)
Add the non-NaN elements of B
to A
, treating NaN
s as zeros
sourceNaNStatistics.nanadd
— Methodnanadd(A, B)
Add the non-NaN elements of A and B, treating NaNs as zeros
sourceNaNStatistics.nanargmax
— Methodnanargmax(A)
As argmax
but ignoring NaN
s: Find the index of the largest non-NaN
value (if any) of an indexable collection A
sourceNaNStatistics.nanargmin
— Methodnanargmin(A)
As argmin
but ignoring NaN
s: Find the index of the smallest non-NaN
value (if any) of an indexable collection A
sourceNaNStatistics.nanbinmean!
— Methodnanbinmean!(MU, N, x, y, z, xedges::AbstractRange, yedges::AbstractRange)
Ignoring NaN
s, fill the matrix MU
with the means and N
with the counts of non-NAN z
values that fall into a 2D grid of x and y bins defined by xedges
and yedges
. The independent variables x
and y
, as well as the dependent variable z
, are all expected as 1D vectors (any subtype of AbstractVector).
The output matrices MU
and N
must be the same size, and must each have length(yedges)-1
rows and length(xedges)-1
columns.
sourceNaNStatistics.nanbinmean!
— Methodnanbinmean!(MU, [N], x, y, xedges::AbstractRange)
Ignoring NaN
s, fill the array MU
with the means (and optionally N
with the counts) of non-NAN y
values that fall into each of length(xedges)-1
equally spaced bins along the x
axis with bin edges specified by xedges
.
The array of x
data should given as a one-dimensional array (any subtype of AbstractVector) and y
as either a 1-d or 2-d array (any subtype of AbstractVecOrMat).
The output arrays MU
and N
must be the same size, and must have the same number of columns as y
; if y
is a 2-d array (matrix), then each column of y
will be treated as a separate variable.
sourceNaNStatistics.nanbinmean
— Methodnanbinmean(x, y, xedges::AbstractRange)
Ignoring NaN
s, calculate the mean of y
values that fall into each of length(xedges)-1
equally spaced bins along the x
axis with bin edges specified by xedges
.
The array of x
data should be given as a one-dimensional array (any subtype of AbstractVector) and y
as either a 1-d or 2-d array (any subtype of AbstractVecOrMat). If y
is a 2-d array, then each column of y
will be treated as a separate variable.
Examples
julia> nanbinmean([1:100..., 1], [1:100..., NaN], 0:25:100)
+ 0 0 0 0 0 0 0 0 0 1
sourceNaNStatistics.inpctile
— Methodinpctile(A, p::Number; dims)
Return a boolean array that identifies which values of the iterable collection A
fall within the central p
th percentile, optionally along a dimension specified by dims
.
A valid percentile value must satisfy 0 <= p <= 100
.
sourceNaNStatistics.movmean
— Methodmovmean(x::AbstractVecOrMat, n::Number)
Simple moving average of x
in 1 or 2 dimensions, spanning n
bins (or n*n in 2D), returning an array of the same size as x
.
For the resulting moving average to be symmetric, n
must be an odd integer; if n
is not an odd integer, the first odd integer greater than n
will be used instead.
sourceNaNStatistics.nanaad
— Methodnanaad(A; dims)
Mean (average) absolute deviation from the mean, ignoring NaN
s, of an indexable collection A
, optionally along a dimension specified by dims
. Note that for a Normal distribution, sigma = 1.253 * AAD.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanadd!
— Methodnanadd!(A, B)
Add the non-NaN elements of B
to A
, treating NaN
s as zeros
sourceNaNStatistics.nanadd
— Methodnanadd(A, B)
Add the non-NaN elements of A and B, treating NaNs as zeros
sourceNaNStatistics.nanargmax
— Methodnanargmax(A)
As argmax
but ignoring NaN
s: Find the index of the largest non-NaN
value (if any) of an indexable collection A
sourceNaNStatistics.nanargmin
— Methodnanargmin(A)
As argmin
but ignoring NaN
s: Find the index of the smallest non-NaN
value (if any) of an indexable collection A
sourceNaNStatistics.nanbinmean!
— Methodnanbinmean!(MU, N, x, y, z, xedges::AbstractRange, yedges::AbstractRange)
Ignoring NaN
s, fill the matrix MU
with the means and N
with the counts of non-NAN z
values that fall into a 2D grid of x and y bins defined by xedges
and yedges
. The independent variables x
and y
, as well as the dependent variable z
, are all expected as 1D vectors (any subtype of AbstractVector).
The output matrices MU
and N
must be the same size, and must each have length(yedges)-1
rows and length(xedges)-1
columns.
sourceNaNStatistics.nanbinmean!
— Methodnanbinmean!(MU, [N], x, y, xedges::AbstractRange)
Ignoring NaN
s, fill the array MU
with the means (and optionally N
with the counts) of non-NAN y
values that fall into each of length(xedges)-1
equally spaced bins along the x
axis with bin edges specified by xedges
.
The array of x
data should given as a one-dimensional array (any subtype of AbstractVector) and y
as either a 1-d or 2-d array (any subtype of AbstractVecOrMat).
The output arrays MU
and N
must be the same size, and must have the same number of columns as y
; if y
is a 2-d array (matrix), then each column of y
will be treated as a separate variable.
sourceNaNStatistics.nanbinmean
— Methodnanbinmean(x, y, xedges::AbstractRange)
Ignoring NaN
s, calculate the mean of y
values that fall into each of length(xedges)-1
equally spaced bins along the x
axis with bin edges specified by xedges
.
The array of x
data should be given as a one-dimensional array (any subtype of AbstractVector) and y
as either a 1-d or 2-d array (any subtype of AbstractVecOrMat). If y
is a 2-d array, then each column of y
will be treated as a separate variable.
Examples
julia> nanbinmean([1:100..., 1], [1:100..., NaN], 0:25:100)
4-element Vector{Float64}:
13.0
38.0
@@ -42,7 +42,7 @@
13.0 113.0 213.0
38.0 138.0 238.0
63.0 163.0 263.0
- 87.5 187.5 287.5
sourceNaNStatistics.nanbinmean
— Methodnanbinmean(x, y, xedges::AbstractRange)
Ignoring NaN
s, calculate the weighted mean of y
values that fall into each of length(xedges)-1
equally spaced bins along the x
axis with bin edges specified by xedges
.
The array of x
data should given as a one-dimensional array (any subtype of AbstractVector) and y
as either a 1-d or 2-d array (any subtype of AbstractVecOrMat). If y
is a 2-d array, then each column of y
will be treated as a separate variable.
sourceNaNStatistics.nanbinmean
— Methodnanbinmean(x, y, z, xedges, yedges)
Ignoring NaN
s, calculate the mean of z
values that fall into a 2D grid of x and y bins with bin edges defined by xedges
and yedges
. The independent variables x
and y
, as well as the dependent variable z
, are all expected as 1D vectors (any subtype of AbstractVector).
Examples
julia> x = y = z = 0.5:9.5;
+ 87.5 187.5 287.5
sourceNaNStatistics.nanbinmean
— Methodnanbinmean(x, y, xedges::AbstractRange)
Ignoring NaN
s, calculate the weighted mean of y
values that fall into each of length(xedges)-1
equally spaced bins along the x
axis with bin edges specified by xedges
.
The array of x
data should given as a one-dimensional array (any subtype of AbstractVector) and y
as either a 1-d or 2-d array (any subtype of AbstractVecOrMat). If y
is a 2-d array, then each column of y
will be treated as a separate variable.
sourceNaNStatistics.nanbinmean
— Methodnanbinmean(x, y, z, xedges, yedges)
Ignoring NaN
s, calculate the mean of z
values that fall into a 2D grid of x and y bins with bin edges defined by xedges
and yedges
. The independent variables x
and y
, as well as the dependent variable z
, are all expected as 1D vectors (any subtype of AbstractVector).
Examples
julia> x = y = z = 0.5:9.5;
julia> xedges = yedges = 0:10;
@@ -57,7 +57,7 @@
NaN NaN NaN NaN NaN NaN 6.5 NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN 7.5 NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN 8.5 NaN
- NaN NaN NaN NaN NaN NaN NaN NaN NaN 9.5
sourceNaNStatistics.nanbinmedian!
— Methodnanbinmedian!(M, [N], x, y, xedges::AbstractRange)
Fill the array M
with the medians (and optionally N
with the counts) of non-NaN y
values that fall into each of length(xedges)-1
equally spaced bins along the x
axis with bin edges specified by xedges
.
If y
is a 2-d array (matrix), each column will be treated as a separate variable
sourceNaNStatistics.nanbinmedian
— Methodnanbinmedian(x, y, xedges::AbstractRange)
Calculate the median, ignoring NaN
s, of y values that fall into each of length(xedges)-1
equally spaced bins along the x
axis with bin edges specified by xedges
.
If y
is a 2-d array (matrix), each column will be treated as a separate variable
Examples
julia> nanbinmedian([1:100..., 1], [1:100..., NaN], 0:25:100)
+ NaN NaN NaN NaN NaN NaN NaN NaN NaN 9.5
sourceNaNStatistics.nanbinmedian!
— Methodnanbinmedian!(M, [N], x, y, xedges::AbstractRange)
Fill the array M
with the medians (and optionally N
with the counts) of non-NaN y
values that fall into each of length(xedges)-1
equally spaced bins along the x
axis with bin edges specified by xedges
.
If y
is a 2-d array (matrix), each column will be treated as a separate variable
sourceNaNStatistics.nanbinmedian
— Methodnanbinmedian(x, y, xedges::AbstractRange)
Calculate the median, ignoring NaN
s, of y values that fall into each of length(xedges)-1
equally spaced bins along the x
axis with bin edges specified by xedges
.
If y
is a 2-d array (matrix), each column will be treated as a separate variable
Examples
julia> nanbinmedian([1:100..., 1], [1:100..., NaN], 0:25:100)
4-element Vector{Float64}:
12.5
37.0
@@ -69,7 +69,7 @@
12.5 112.5 212.5
37.0 137.0 237.0
62.0 162.0 262.0
- 87.0 187.0 287.0
sourceNaNStatistics.nancor
— Methodnancor(X::AbstractMatrix; dims::Int=1)
Compute the (Pearson's product-moment) correlation matrix of the matrix X
, along dimension dims
. As Statistics.cor
, but ignoring NaN
s.
sourceNaNStatistics.nancor
— Methodnancor(x::AbstractVector, y::AbstractVector)
Compute the (Pearson's product-moment) correlation between the vectors x
and y
. As Statistics.cor
, but ignoring NaN
s.
Equivalent to nancov(x,y) / (nanstd(x) * nanstd(y))
.
sourceNaNStatistics.nancov
— Methodnancov(X::AbstractMatrix; dims::Int=1, corrected::Bool=true)
Compute the covariance matrix of the matrix X
, along dimension dims
. As Statistics.cov
, but ignoring NaN
s.
If corrected
is true
as is the default, Bessel's correction will be applied, such that the sum is scaled by n-1
rather than n
, where n = length(x)
.
sourceNaNStatistics.nancov
— Methodnancov(x::AbstractVector, y::AbstractVector; corrected::Bool=true)
Compute the covariance between the vectors x
and y
. As Statistics.cov
, but ignoring NaN
s.
If corrected
is true
as is the default, Bessel's correction will be applied, such that the sum is scaled by n-1
rather than n
, where n = length(x)
.
sourceNaNStatistics.nancumsum
— Methodnancumsum(A; dims)
Calculate the sum of an indexable collection A
, ignoring NaN
s, optionally along dimensions specified by dims
.
Examples
```julia julia> using NaNStatistics
julia> A = [1 2; 3 4; NaN NaN] 3×2 Matrix{Float64}: 1.0 2.0 3.0 4.0 NaN NaN
julia> nancumsum(A, dims=1) 3×2 Matrix{Float64}: 1.0 2.0 4.0 6.0 4.0 6.0
julia> nancumsum(vec(A)) 6-element Vector{Float64}: 1.0 4.0 4.0 6.0 10.0 10.0
sourceNaNStatistics.nanextrema
— Methodnanextrema(A; dims)
Find the extrema (maximum & minimum) of an indexable collection A
, ignoring NaN
s, optionally along a dimension specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanmad!
— Methodnanmad!(A; dims)
As nanmad
but in-place.
sourceNaNStatistics.nanmad
— Methodnanmad(A; dims)
Median absolute deviation from the median, ignoring NaN
s, of an indexable collection A
, optionally along a dimension specified by dims
. Note that for a Normal distribution, sigma = 1.4826 * MAD.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanmask!
— Methodnanmask!(mask, A)
Fill a Boolean mask of dimensions size(A)
that is false wherever A
is NaN
sourceNaNStatistics.nanmask
— Methodnanmask(A)
Create a Boolean mask of dimensions size(A)
that is false wherever A
is NaN
sourceNaNStatistics.nanmax
— Methodnanmax(a,b)
As max(a,b)
, but if either argument is NaN
, return the other one
sourceNaNStatistics.nanmaximum
— Methodnanmaximum(A; dims)
As maximum
but ignoring NaN
s: Find the largest non-NaN
value of an indexable collection A
, optionally along a dimension specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanmean
— Methodnanmean(A, W; dims)
Ignoring NaN
s, calculate the weighted mean of an indexable collection A
, optionally along dimensions specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanmean
— Methodnanmean(A; dims)
Compute the mean of all non-NaN
elements in A
, optionally over dimensions specified by dims
. As Statistics.mean
, but ignoring NaN
s.
As an alternative to dims
, nanmean
also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
Examples
julia> using NaNStatistics
+ 87.0 187.0 287.0
sourceNaNStatistics.nancor
— Methodnancor(X::AbstractMatrix; dims::Int=1)
Compute the (Pearson's product-moment) correlation matrix of the matrix X
, along dimension dims
. As Statistics.cor
, but ignoring NaN
s.
sourceNaNStatistics.nancor
— Methodnancor(x::AbstractVector, y::AbstractVector)
Compute the (Pearson's product-moment) correlation between the vectors x
and y
. As Statistics.cor
, but ignoring NaN
s.
Equivalent to nancov(x,y) / (nanstd(x) * nanstd(y))
.
sourceNaNStatistics.nancov
— Methodnancov(X::AbstractMatrix; dims::Int=1, corrected::Bool=true)
Compute the covariance matrix of the matrix X
, along dimension dims
. As Statistics.cov
, but ignoring NaN
s.
If corrected
is true
as is the default, Bessel's correction will be applied, such that the sum is scaled by n-1
rather than n
, where n = length(x)
.
sourceNaNStatistics.nancov
— Methodnancov(x::AbstractVector, y::AbstractVector; corrected::Bool=true)
Compute the covariance between the vectors x
and y
. As Statistics.cov
, but ignoring NaN
s.
If corrected
is true
as is the default, Bessel's correction will be applied, such that the sum is scaled by n-1
rather than n
, where n = length(x)
.
sourceNaNStatistics.nancumsum
— Methodnancumsum(A; dims)
Calculate the sum of an indexable collection A
, ignoring NaN
s, optionally along dimensions specified by dims
.
Examples
```julia julia> using NaNStatistics
julia> A = [1 2; 3 4; NaN NaN] 3×2 Matrix{Float64}: 1.0 2.0 3.0 4.0 NaN NaN
julia> nancumsum(A, dims=1) 3×2 Matrix{Float64}: 1.0 2.0 4.0 6.0 4.0 6.0
julia> nancumsum(vec(A)) 6-element Vector{Float64}: 1.0 4.0 4.0 6.0 10.0 10.0
sourceNaNStatistics.nanextrema
— Methodnanextrema(A; dims)
Find the extrema (maximum & minimum) of an indexable collection A
, ignoring NaN
s, optionally along a dimension specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanmad!
— Methodnanmad!(A; dims)
As nanmad
but in-place.
sourceNaNStatistics.nanmad
— Methodnanmad(A; dims)
Median absolute deviation from the median, ignoring NaN
s, of an indexable collection A
, optionally along a dimension specified by dims
. Note that for a Normal distribution, sigma = 1.4826 * MAD.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanmask!
— Methodnanmask!(mask, A)
Fill a Boolean mask of dimensions size(A)
that is false wherever A
is NaN
sourceNaNStatistics.nanmask
— Methodnanmask(A)
Create a Boolean mask of dimensions size(A)
that is false wherever A
is NaN
sourceNaNStatistics.nanmax
— Methodnanmax(a,b)
As max(a,b)
, but if either argument is NaN
, return the other one
sourceNaNStatistics.nanmaximum
— Methodnanmaximum(A; dims)
As maximum
but ignoring NaN
s: Find the largest non-NaN
value of an indexable collection A
, optionally along a dimension specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanmean
— Methodnanmean(A, W; dims)
Ignoring NaN
s, calculate the weighted mean of an indexable collection A
, optionally along dimensions specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanmean
— Methodnanmean(A; dims)
Compute the mean of all non-NaN
elements in A
, optionally over dimensions specified by dims
. As Statistics.mean
, but ignoring NaN
s.
As an alternative to dims
, nanmean
also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
Examples
julia> using NaNStatistics
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
@@ -83,7 +83,7 @@
julia> nanmean(A, dims=2)
2×1 Matrix{Float64}:
1.5
- 3.5
sourceNaNStatistics.nanmedian!
— Methodnanmedian!(A; dims)
Compute the median of all elements in A
, optionally over dimensions specified by dims
. As Statistics.median!
, but ignoring NaN
s and supporting the dims
keyword.
Be aware that, like Statistics.median!
, this function modifies A
, sorting or partially sorting the contents thereof (specifically, along the dimensions specified by dims
, using either quicksort!
or quickselect!
around the median depending on the size of the array). Do not use this function if you do not want the contents of A
to be rearranged.
Reduction over multiple dims
is not officially supported, though does work (in generally suboptimal time) as long as the dimensions being reduced over are all contiguous.
Optionally supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
Examples
julia> using NaNStatistics
+ 3.5
sourceNaNStatistics.nanmedian!
— Methodnanmedian!(A; dims)
Compute the median of all elements in A
, optionally over dimensions specified by dims
. As Statistics.median!
, but ignoring NaN
s and supporting the dims
keyword.
Be aware that, like Statistics.median!
, this function modifies A
, sorting or partially sorting the contents thereof (specifically, along the dimensions specified by dims
, using either quicksort!
or quickselect!
around the median depending on the size of the array). Do not use this function if you do not want the contents of A
to be rearranged.
Reduction over multiple dims
is not officially supported, though does work (in generally suboptimal time) as long as the dimensions being reduced over are all contiguous.
Optionally supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
Examples
julia> using NaNStatistics
julia> A = [1 2 3; 4 5 6; 7 8 9]
3×3 Matrix{Int64}:
@@ -108,7 +108,7 @@
3×3 Matrix{Int64}:
1 4 7
2 5 8
- 3 6 9
sourceNaNStatistics.nanmedian
— Methodnanmedian(A; dims)
Calculate the median, ignoring NaNs, of an indexable collection A
, optionally along a dimension specified by dims
.
Reduction over multiple dims
is not officially supported, though does work (in generally suboptimal time) as long as the dimensions being reduced over are all contiguous.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanmin
— Methodnanmin(a,b)
As min(a,b)
, but if either argument is NaN
, return the other one
sourceNaNStatistics.nanminimum
— Methodnanminimum(A; dims)
As minimum
but ignoring NaN
s: Find the smallest non-NaN
value of an indexable collection A
, optionally along a dimension specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanpctile!
— Methodnanpctile!(A, p; dims)
Compute the p
th percentile (where p ∈ [0,100]
) of all elements in A
, ignoring NaN
s, optionally over dimensions specified by dims
.
As StatsBase.percentile
, but in-place, ignoring NaN
s, and supporting the dims
keyword.
Be aware that, like Statistics.median!
, this function modifies A
, sorting or partially sorting the contents thereof (specifically, along the dimensions specified by dims
, using either quicksort!
or quickselect!
depending on the size of the array). Do not use this function if you do not want the contents of A
to be rearranged.
Reduction over multiple dims
is not officially supported, though does work (in generally suboptimal time) as long as the dimensions being reduced over are all contiguous.
Examples
julia> using NaNStatistics
+ 3 6 9
sourceNaNStatistics.nanmedian
— Methodnanmedian(A; dims)
Calculate the median, ignoring NaNs, of an indexable collection A
, optionally along a dimension specified by dims
.
Reduction over multiple dims
is not officially supported, though does work (in generally suboptimal time) as long as the dimensions being reduced over are all contiguous.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanmin
— Methodnanmin(a,b)
As min(a,b)
, but if either argument is NaN
, return the other one
sourceNaNStatistics.nanminimum
— Methodnanminimum(A; dims)
As minimum
but ignoring NaN
s: Find the smallest non-NaN
value of an indexable collection A
, optionally along a dimension specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanpctile!
— Methodnanpctile!(A, p; dims)
Compute the p
th percentile (where p ∈ [0,100]
) of all elements in A
, ignoring NaN
s, optionally over dimensions specified by dims
.
As StatsBase.percentile
, but in-place, ignoring NaN
s, and supporting the dims
keyword.
Be aware that, like Statistics.median!
, this function modifies A
, sorting or partially sorting the contents thereof (specifically, along the dimensions specified by dims
, using either quicksort!
or quickselect!
depending on the size of the array). Do not use this function if you do not want the contents of A
to be rearranged.
Reduction over multiple dims
is not officially supported, though does work (in generally suboptimal time) as long as the dimensions being reduced over are all contiguous.
Examples
julia> using NaNStatistics
julia> A = [1 2 3; 4 5 6; 7 8 9]
3×3 Matrix{Int64}:
@@ -133,7 +133,7 @@
3×3 Matrix{Int64}:
1 4 7
2 5 8
- 3 6 9
sourceNaNStatistics.nanpctile
— Methodnanpctile(A, p; dims)
Find the p
th percentile (where 0 <= p <= 100
) of an indexable collection A
, ignoring NaNs, optionally along a dimension specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
See also nanpctile!
for a more efficient in-place variant.
sourceNaNStatistics.nanquantile!
— Methodnanquantile!(A, q; dims)
Compute the q
th quantile (where q ∈ [0,1]
) of all elements in A
, ignoring NaN
s, optionally over dimensions specified by dims
.
Similar to StatsBase.quantile!
, but ignoring NaN
s, and supporting the dims
keyword.
Be aware that, like StatsBase.quantile!
, this function modifies A
, sorting or partially sorting the contents thereof (specifically, along the dimensions specified by dims
, using either quicksort!
or quickselect!
depending on the size of the array). Do not use this function if you do not want the contents of A
to be rearranged.
Reduction over multiple dims
is not officially supported, though does work (in generally suboptimal time) as long as the dimensions being reduced over are all contiguous.
Examples
julia> using NaNStatistics
+ 3 6 9
sourceNaNStatistics.nanpctile
— Methodnanpctile(A, p; dims)
Find the p
th percentile (where 0 <= p <= 100
) of an indexable collection A
, ignoring NaNs, optionally along a dimension specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
See also nanpctile!
for a more efficient in-place variant.
sourceNaNStatistics.nanquantile!
— Methodnanquantile!(A, q; dims)
Compute the q
th quantile (where q ∈ [0,1]
) of all elements in A
, ignoring NaN
s, optionally over dimensions specified by dims
.
Similar to StatsBase.quantile!
, but ignoring NaN
s, and supporting the dims
keyword.
Be aware that, like StatsBase.quantile!
, this function modifies A
, sorting or partially sorting the contents thereof (specifically, along the dimensions specified by dims
, using either quicksort!
or quickselect!
depending on the size of the array). Do not use this function if you do not want the contents of A
to be rearranged.
Reduction over multiple dims
is not officially supported, though does work (in generally suboptimal time) as long as the dimensions being reduced over are all contiguous.
Examples
julia> using NaNStatistics
julia> A = [1 2 3; 4 5 6; 7 8 9]
3×3 Matrix{Int64}:
@@ -158,7 +158,21 @@
3×3 Matrix{Int64}:
1 4 7
2 5 8
- 3 6 9
sourceNaNStatistics.nanquantile
— Methodnanquantile(A, q; dims)
Compute the q
th quantile (where q ∈ [0,1]
) of all elements in A
, ignoring NaN
s, optionally over dimensions specified by dims
.
Reduction over multiple dims
is not officially supported, though does work (in generally suboptimal time) as long as the dimensions being reduced over are all contiguous.
See also nanquantile!
for a more efficient in-place variant.
sourceNaNStatistics.nanrange
— Methodnanrange(A; dims)
Calculate the range (maximum - minimum) of an indexable collection A
, ignoring NaN
s, optionally along a dimension specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanstandardize!
— Methodnanstandardize!(A::Array{<:AbstractFloat}; dims)
Rescale A
to unit variance and zero mean i.e. A .= (A .- nanmean(A)) ./ nanstd(A)
sourceNaNStatistics.nanstandardize
— Methodnanstandardize(A; dims)
Rescale a copy of A
to unit variance and zero mean i.e. (A .- nanmean(A)) ./ nanstd(A)
sourceNaNStatistics.nanstd
— Methodnanstd(A, W; dims)
Calculate the weighted standard deviation, ignoring NaN
s, of an indexable collection A
, optionally along a dimension specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanstd
— Methodnanstd(A; dims=:, mean=nothing, corrected=true)
Compute the variance of all non-NaN
elements in A
, optionally over dimensions specified by dims
. As Statistics.var
, but ignoring NaN
s.
A precomputed mean
may optionally be provided, which results in a somewhat faster calculation. If corrected
is true
, then Bessel's correction is applied, such that the sum is divided by n-1
rather than n
.
As an alternative to dims
, nanstd
also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
Examples
julia> using NaNStatistics
+ 3 6 9
sourceNaNStatistics.nanquantile
— Methodnanquantile(A, q; dims)
Compute the q
th quantile (where q ∈ [0,1]
) of all elements in A
, ignoring NaN
s, optionally over dimensions specified by dims
.
Reduction over multiple dims
is not officially supported, though does work (in generally suboptimal time) as long as the dimensions being reduced over are all contiguous.
See also nanquantile!
for a more efficient in-place variant.
sourceNaNStatistics.nanrange
— Methodnanrange(A; dims)
Calculate the range (maximum - minimum) of an indexable collection A
, ignoring NaN
s, optionally along a dimension specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nansem
— Methodnansem(A; dims=:, mean=nothing, corrected=true)
Compute the standard error of the mean of all non-NaN
elements in A
, optionally over dimensions specified by dims
.
A precomputed mean
may optionally be provided, which results in a somewhat faster calculation. If corrected
is true
, then Bessel's correction is applied, such that the sum is divided by n-1
rather than n
.
As an alternative to dims
, nansem
also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
Examples
julia> using NaNStatistics
+
+julia> A = [1 2; 3 4]
+2×2 Matrix{Int64}:
+ 1 2
+ 3 4
+
+julia> nansem(A, dims=1)
+1×2 Matrix{Float64}:
+ 2.0 2.0
+
+julia> nansem(A, dims=2)
+2×1 Matrix{Float64}:
+ 0.5
+ 0.5
sourceNaNStatistics.nanstandardize!
— Methodnanstandardize!(A::Array{<:AbstractFloat}; dims)
Rescale A
to unit variance and zero mean i.e. A .= (A .- nanmean(A)) ./ nanstd(A)
sourceNaNStatistics.nanstandardize
— Methodnanstandardize(A; dims)
Rescale a copy of A
to unit variance and zero mean i.e. (A .- nanmean(A)) ./ nanstd(A)
sourceNaNStatistics.nanstd
— Methodnanstd(A, W; dims)
Calculate the weighted standard deviation, ignoring NaN
s, of an indexable collection A
, optionally along a dimension specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
sourceNaNStatistics.nanstd
— Methodnanstd(A; dims=:, mean=nothing, corrected=true)
Compute the variance of all non-NaN
elements in A
, optionally over dimensions specified by dims
. As Statistics.var
, but ignoring NaN
s.
A precomputed mean
may optionally be provided, which results in a somewhat faster calculation. If corrected
is true
, then Bessel's correction is applied, such that the sum is divided by n-1
rather than n
.
As an alternative to dims
, nanstd
also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
Examples
julia> using NaNStatistics
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
@@ -172,7 +186,7 @@
julia> nanstd(A, dims=2)
2×1 Matrix{Float64}:
0.7071067811865476
- 0.7071067811865476
sourceNaNStatistics.nansum
— Methodnansum(A; dims)
Calculate the sum of an indexable collection A
, ignoring NaN
s, optionally along dimensions specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
Examples
julia> using NaNStatistics
+ 0.7071067811865476
sourceNaNStatistics.nansum
— Methodnansum(A; dims)
Calculate the sum of an indexable collection A
, ignoring NaN
s, optionally along dimensions specified by dims
.
Also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
Examples
julia> using NaNStatistics
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
@@ -186,7 +200,7 @@
julia> nansum(A, dims=2)
2×1 Matrix{Int64}:
3
- 7
sourceNaNStatistics.nanvar
— Methodnanvar(A; dims=:, mean=nothing, corrected=true)
Compute the variance of all non-NaN
elements in A
, optionally over dimensions specified by dims
. As Statistics.var
, but ignoring NaN
s.
A precomputed mean
may optionally be provided, which results in a somewhat faster calculation. If corrected
is true
, then Bessel's correction is applied, such that the sum is divided by n-1
rather than n
.
As an alternative to dims
, nanvar
also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
Examples
julia> using NaNStatistics
+ 7
sourceNaNStatistics.nanvar
— Methodnanvar(A; dims=:, mean=nothing, corrected=true)
Compute the variance of all non-NaN
elements in A
, optionally over dimensions specified by dims
. As Statistics.var
, but ignoring NaN
s.
A precomputed mean
may optionally be provided, which results in a somewhat faster calculation. If corrected
is true
, then Bessel's correction is applied, such that the sum is divided by n-1
rather than n
.
As an alternative to dims
, nanvar
also supports the dim
keyword, which behaves identically to dims
, but also drops any singleton dimensions that have been reduced over (as is the convention in some other languages).
Examples
julia> using NaNStatistics
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
@@ -200,4 +214,4 @@
julia> nanvar(A, dims=2)
2×1 Matrix{Float64}:
0.5
- 0.5
sourceNaNStatistics.zeronan!
— Methodzeronan!(A)
Replace all NaN
s in A with zeros of the same type
sourceSettings
This document was generated with Documenter.jl on Tuesday 5 December 2023. Using Julia version 1.9.4.
+ 0.5
NaNStatistics.zeronan!
— Methodzeronan!(A)
Replace all NaN
s in A with zeros of the same type