Julep: allow passing an operator to `var`
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with the var(a) and var(a; dims=1) examples in the issue, then read the linked ColorVectorSpace discussion and consider the coordination with StaticArrays. Done would require an agreed operator-passing API for var and corresponding behavior for dot, elementwise, and outer-product cases.
Written by the indexing model from the issue text.
Description
This is a bit of a cross-post from https://github.com/JuliaGraphics/ColorVectorSpace.jl/issues/126, but let me provide a more succinct summary specialized to this package. Consider the following demo:
julia> using Statistics, StaticArrays
julia> a = rand(SVector{3,Float32}, 3)
3-element Array{SArray{Tuple{3},Float32,1,3},1}:
[0.46784067, 0.55236137, 0.30518198]
[0.45679474, 0.8746067, 0.7767879]
[0.30195618, 0.48870897, 0.37561262]
julia> var(a)
3-element SArray{Tuple{3},Float32,1,3} with indices SOneTo(3):
0.008602443
0.042801797
0.06471903
julia> var(a; dims=1)
ERROR: MethodError: no method matching abs2(::SArray{Tuple{3},Float32,1,3})
Closest candidates are:
abs2(::Missing) at missing.jl:100
abs2(::Bool) at bool.jl:84
abs2(::Real) at number.jl:157
...
Stacktrace:
There's a sense in which the error is the correct outcome, and the one that returns a vector is a bit of a misnomer; after all, the definition of var as E[(X-μ)^2] requires that one can compute y^2 for objects drawn from X, but * does not mean elementwise multiplication.
Over in ColorVectorSpace we've hit upon the following idea: defining ⋅ (\cdot) as the "dot product", ⊙ operating elementwise (like broadcasting-* but we can't pass that as a function argument and therefore need a different operator), and ⊗ (\otimes) to mean the outer product. In that circumstance, var(⋅, a) becomes the mean-square-error, var(⊙, a) becomes the elementwise variance, and var(⊗, a) is the covariance.
I'd be interested in your thoughts. I also think it makes sense for ColorVectorSpace and maybe StaticArrays (CC @c42f) to synchronize, if possible.
- Dominant language
- Julia
- Stars
- 93
- Forks
- 51
- PR merge metrics
- No merged PRs in 30d
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/Statistics.jl
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
JuliaStats/Statistics.jl#221 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
JuliaStats/Statistics.jl#219 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JuliaStats/Statistics.jl#207 · 1 comment ·
-
Difficulty 3/5 Half a day Newbie friendliness 55/100
JuliaStats/Statistics.jl#220 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
JuliaStats/Statistics.jl#215 · 1 reaction ·
All issues in JuliaStats/Statistics.jl
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JuliaParallel/Hwloc.jl#93 ·
-
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