-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add StatsBase extension and weigthed stats
- Loading branch information
Showing
4 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module DimensionalDataStatsBase | ||
|
||
using DimensionalData | ||
using Statistics | ||
using StatsBase | ||
|
||
const DD = DimensionalData | ||
|
||
function Statistics.mean(A::AbstractDimArray, w::StatsBase.AbstractWeights; dims=:) | ||
data = mean(parent(A), w; dims=dimnum(A, dims)) | ||
return rebuild(A, data, DD.reducedims(A, dims)) | ||
end | ||
# For ambiguity | ||
function Statistics.mean(A::AbstractDimArray, w::StatsBase.UnitWeights; dims=:) | ||
data = mean(parent(A), w; dims=dimnum(A, dims)) | ||
return rebuild(A, data, DD.reducedims(A, dims)) | ||
end | ||
|
||
function Base.sum(A::AbstractDimArray, w::AbstractWeights{<:Real}; dims=:) | ||
data = sum(parent(A), w; dims=dimnum(A, dims)) | ||
return rebuild(A, data, DD.reducedims(A, dims)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters