Missing methods for moments of complex random variable
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by reproducing the shown failures and reading StatsBase/src/moments.jl, especially the existing Real-only methods for moment, var, and mean_and_var. Determine the intended definitions for complex and weighted first and second moments, including the variance convention. Done means the requested complex-valued calls work consistently with the existing unweighted behavior and have coverage for the demonstrated cases.
Written by the indexing model from the issue text.
Description
Hi,
It seems that some methods are missing to compute the firsts 2 (weighted) moments of complex random variables.
Is any conceptual issues that prevents me to propose a PR implementing these?
julia> N = 1_000_000;
julia> x = randn(N);
julia> xc = randn(ComplexF64,N);
julia> w = rand(N);
julia> mean(x)
-0.0006234813354142627
julia> mean(xc)
0.0002818700630158139 + 0.0004029044695052171im
julia> var(x)
0.9994220449190467
julia> var(xc)
1.000575477440655
julia> moment(xc,1)
ERROR: MethodError: no method matching moment(::Vector{ComplexF64}, ::Int64)
The function `moment` exists, but no method is defined for this combination of argument types.
Closest candidates are:
moment(::AbstractArray{<:Real}, ::Int64)
@ StatsBase ~/.julia/packages/StatsBase/lRQEN/src/moments.jl:314
moment(::AbstractArray{<:Real}, ::Int64, ::Real)
@ StatsBase ~/.julia/packages/StatsBase/lRQEN/src/moments.jl:314
moment(::AbstractArray{<:Real}, ::Int64, ::AbstractWeights)
@ StatsBase ~/.julia/packages/StatsBase/lRQEN/src/moments.jl:321
...
Stacktrace:
[1] top-level scope
@ REPL[59]:1
julia> moment(x,1)
-1.2931877790833823e-17
julia> wsum(xc,w)
180.43932062446382 + 205.28102880933926im
julia> mean(xc,weights(w))
0.00036099221296754424 + 0.00041069126515038817im
julia> var(xc,weights(w))
ERROR: MethodError: no method matching var(::Vector{ComplexF64}, ::Weights{Float64, Float64, Vector{Float64}})
The function `var` exists, but no method is defined for this combination of argument types.
Closest candidates are:
var(::CovarianceEstimator, ::AbstractVector; kwargs...)
@ StatsBase ~/.julia/packages/StatsBase/lRQEN/src/cov.jl:296
var(::AbstractArray{<:Real}, ::AbstractWeights, ::Int64; mean, corrected)
@ StatsBase ~/.julia/packages/StatsBase/lRQEN/src/moments.jl:63
var(::AbstractArray; corrected, mean, dims)
@ Statistics ~/.julia/packages/Statistics/gbcbG/src/Statistics.jl:380
...
Stacktrace:
[1] top-level scope
@ REPL[63]:1
julia> mean_and_var(x, weights(w))
(0.00035486592111588897, 0.9988627381401368)
julia> mean_and_var(xc, weights(w))
ERROR: MethodError: no method matching mean_and_var(::Vector{ComplexF64}, ::Weights{Float64, Float64, Vector{Float64}})
The function `mean_and_var` exists, but no method is defined for this combination of argument types.
Closest candidates are:
mean_and_var(::Any; corrected)
@ StatsBase ~/.julia/packages/StatsBase/lRQEN/src/moments.jl:117
mean_and_var(::AbstractArray{<:Real}, ::AbstractWeights; corrected)
@ StatsBase ~/.julia/packages/StatsBase/lRQEN/src/moments.jl:139
mean_and_var(::AbstractArray{<:Real}, ::AbstractWeights, ::Int64; corrected)
@ StatsBase ~/.julia/packages/StatsBase/lRQEN/src/moments.jl:163
...
Stacktrace:
[1] top-level scope
@ REPL[65]:1
julia> mean_and_var(xc)
(0.0002818700630158139 + 0.0004029044695052171im, 1.000575477440655)
- Dominant language
- Julia
- Stars
- 615
- Forks
- 198
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 5
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaStats/StatsBase.jl
-
TransformationsOpen
Difficulty 5/5 Over a week Newbie friendliness 35/100
JuliaStats/StatsBase.jl#1012 ·
Maintainers usually reply within 1 day
-
Data loss with floating-point `Histogram`sPossibly taken @andreasnoack claimed this 76 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 78/100
JuliaStats/StatsBase.jl#1009 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
JuliaStats/StatsBase.jl#1006 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
JuliaStats/StatsBase.jl#998 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
JuliaStats/StatsBase.jl#988 ·
Maintainers usually reply within 1 day
All issues in JuliaStats/StatsBase.jl
Similar issues
-
Affine transformations of `JohnsonSU` could return a `JohnsonSU`Possibly taken @devmotion claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JuliaStats/Distributions.jl#2117 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
TomerAberbach/profiler-md#970 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
grame-cncm/faust#1409 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
SciML/PETScDiffEq.jl#521 ·
Maintainers usually reply within 1 day