Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: expand data by FrequencyWeights #314

Closed
wants to merge 1 commit into from
Closed

WIP: expand data by FrequencyWeights #314

wants to merge 1 commit into from

Conversation

joshday
Copy link
Contributor

@joshday joshday commented Nov 1, 2017

This PR adds a repeat(x::RealVector, w::FrequencyWeight{<:Integer}) method to create a new vector where each element in x gets repeated by its associated weight in w. Would this be useful, if only for better testing? It would help catch cases like #313

x = randn(10)
w = rand(1:5, 10)
p = [0, .25, .5, .75, 1]
@test quantile(x, w, p) == quantile(repeat(x, w), p)

@codecov
Copy link

codecov bot commented Nov 1, 2017

Codecov Report

Merging #314 into master will decrease coverage by 0.18%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #314      +/-   ##
=========================================
- Coverage   90.88%   90.7%   -0.19%     
=========================================
  Files          18      18              
  Lines        1964    1957       -7     
=========================================
- Hits         1785    1775      -10     
- Misses        179     182       +3
Impacted Files Coverage Δ
src/weights.jl 86.09% <0%> (-2.8%) ⬇️
src/hist.jl 95.38% <0%> (-0.07%) ⬇️
src/moments.jl 99.4% <0%> (-0.01%) ⬇️
src/cov.jl 100% <0%> (ø) ⬆️
src/sampling.jl 92.11% <0%> (+1.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e9d724...588fc45. Read the comment docs.

@joshday
Copy link
Contributor Author

joshday commented Nov 3, 2017

Oops, this already exists.

StatsBase.inverse_rle([1,2,3], fweights([1,2,3]))

@joshday joshday closed this Nov 3, 2017
@joshday joshday deleted the josh/rep branch November 3, 2017 13:34
@nalimilan
Copy link
Member

It would make sense to rename that function as it's pretty hard to discover. I even had filed an issue against Julia to add this kind of function without noticing it existed here: JuliaLang/julia#16443.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants