Merge pull request #1174 from mkborregaard/fix_hist_weights

fix `weights` in `histogram`; closes #1173
This commit is contained in:
Michael Krabbe Borregaard 2017-10-13 17:09:06 +02:00 committed by GitHub
commit dcc3055dec
2 changed files with 2 additions and 2 deletions

View File

@ -145,7 +145,7 @@ PlotExample("Bar",
PlotExample("Histogram",
"",
[:(begin
histogram(randn(1000), nbins=20)
histogram(randn(1000), bins = :scott, weights = repeat(1:5, outer = 200))
end)]
),

View File

@ -550,7 +550,7 @@ function _make_hist{N}(vs::NTuple{N,AbstractVector}, binning; normed = false, we
edges = _hist_edges(vs, binning)
h = float( weights == nothing ?
StatsBase.fit(StatsBase.Histogram, vs, edges, closed = :left) :
StatsBase.fit(StatsBase.Histogram, vs, weights, edges, closed = :left)
StatsBase.fit(StatsBase.Histogram, vs, StatsBase.Weights(weights), edges, closed = :left)
)
normalize!(h, mode = _hist_norm_mode(normed))
end