hep
hep copied to clipboard
hbook: retrieve x position of maximum within given range for H1D
From @ebusato on October 12, 2016 15:10
Hi,
I'd like to retrieve the position on the x axis of the y maximum of the histogram within a certain range provided by the user. Right now you have the Max() method that returns the y maximum. What do you think would be the best option to implement what I need :
- Change the Max() method by adding two parameters to specify the range and one return value which is the maximum position on the x axis
- Create a new method and let Max() untouched in order to not impact clients.
?
Let me know and I'll send a PR.
Emmanuel
Copied from original issue: go-hep/hbook#8
I see 2 additional options:
-
make
Max()
a variadic method, likeIntegral()
:// Max returns the maximum y value of this histogram. func (h *H1D) Max(args ...float64) float64 { ... }
-
make
Max()
take aRange1D
argument:type Range1D [2]float64 // Max returns the maximum y value of this histogram. func (h *H1D) Max(span Range1D) float64 { ... }
where
Range1D
default value(0,0)
would implicitly mean the whole 1D axis.
From @ebusato on October 13, 2016 8:56
Right. I would go for the variadic option, with the aditionnal return value. So the signature would be:
// Max returns the maximum y value of this histogram and the corresponding x value. func (h *H1D) Max(args ...float64) (float64, float64) { ... }
Would that be ok for you ?
sounds good to me