MCPcopy Index your code
hub / github.com/gonum/plot / quantilesR7

Function quantilesR7

plotter/contour.go:99–120  ·  view source on GitHub ↗

quantilesR7 returns the pth quantiles of the data in g according to the R-7 method. http://en.wikipedia.org/wiki/Quantile#Estimating_the_quantiles_of_a_population

(g GridXYZ, p []float64)

Source from the content-addressed store, hash-verified

97// quantilesR7 returns the pth quantiles of the data in g according to the R-7 method.
98// http://en.wikipedia.org/wiki/Quantile#Estimating_the_quantiles_of_a_population
99func quantilesR7(g GridXYZ, p []float64) []float64 {
100 c, r := g.Dims()
101 data := make([]float64, 0, c*r)
102 for i := range c {
103 for j := range r {
104 if v := g.Z(i, j); !math.IsNaN(v) {
105 data = append(data, v)
106 }
107 }
108 }
109 sort.Float64s(data)
110 v := make([]float64, len(p))
111 for j, q := range p {
112 if q == 1 {
113 v[j] = data[len(data)-1]
114 }
115 h := float64(len(data)-1) * q
116 i := int(h)
117 v[j] = data[i] + (h-math.Floor(h))*(data[i+1]-data[i])
118 }
119 return v
120}
121
122// naive is a debugging constant. If true, Plot performs no contour path
123// reconstruction, instead rendering each path segment individually.

Callers 1

NewContourFunction · 0.85

Calls 2

DimsMethod · 0.65
ZMethod · 0.65

Tested by

no test coverage detected