StatsBase.jl icon indicating copy to clipboard operation
StatsBase.jl copied to clipboard

y errorbar for the Histogram

Open mmikhasenko opened this issue 4 years ago • 6 comments

I would like to assign an errorbar to histogram weights (when plotting), Usually, Binomial or Poisson distribution is assumed for the number of entries, so the error reads sqrt(weight).

To calculate the error with weighted data, I need to access a sample of data weighs that enter a particular bin, not just Histogram.weights. Is there a way to do it?

mmikhasenko avatar Sep 01 '20 09:09 mmikhasenko

I think there are two options:

  • computing bin error at on the fit(Histogram) call, or
  • keeping an array of weights for every bin that errors can be computed later using any strategy preferred. What do you think is more realistic to implement in StatsBase?

mmikhasenko avatar Sep 27 '20 21:09 mmikhasenko

Should one create a separate type <: AbstractHistogram or extend the existing one?

mmikhasenko avatar Sep 27 '20 21:09 mmikhasenko

I remember the AIDA project a while ago, which keeps around the bin entries, weights and weights^2. cc @joshday for how to deal with this in OnlineStats.

jstrube avatar Nov 08 '20 22:11 jstrube

that is what I codded at the end, but I would love to change and extend some existing, more mature package

mmikhasenko avatar Nov 09 '20 09:11 mmikhasenko

OnlineStats doesn't do StatsBase-like weighting, mainly because I haven't figured out the right interface for it. There is https://github.com/gdkrmr/WeightedOnlineStats.jl where you could use a per-bin WeightedVariance.

joshday avatar Nov 18 '20 14:11 joshday

@mmikhasenko currently making 1D and 2D histograms with errors (sqrt and pearson, so up and down are recorded separately), part of my Final project so something should come out before the year ends for sure ;)

Moelf avatar Nov 26 '20 06:11 Moelf