MCPcopy
hub / github.com/nats-io/nats.go / StdDev

Method StdDev

bench/bench.go:229–240  ·  view source on GitHub ↗

StdDev returns the standard deviation the message rates in the SampleGroup

()

Source from the content-addressed store, hash-verified

227
228// StdDev returns the standard deviation the message rates in the SampleGroup
229func (sg *SampleGroup) StdDev() float64 {
230 if !sg.HasSamples() {
231 return 0
232 }
233 avg := float64(sg.AvgRate())
234 sum := float64(0)
235 for _, c := range sg.Samples {
236 sum += math.Pow(float64(c.Rate())-avg, 2)
237 }
238 variance := sum / float64(len(sg.Samples))
239 return math.Sqrt(variance)
240}
241
242// AddSample adds a Sample to the SampleGroup. After adding a Sample it shouldn't be modified.
243func (sg *SampleGroup) AddSample(e *Sample) {

Callers 2

TestStdDevFunction · 0.95
StatisticsMethod · 0.95

Calls 3

HasSamplesMethod · 0.95
AvgRateMethod · 0.95
RateMethod · 0.80

Tested by 1

TestStdDevFunction · 0.76