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

Function NewErrorPoints

plotutil/errorpoints.go:32–60  ·  view source on GitHub ↗

NewErrorPoints returns a new ErrorPoints where each point in the ErrorPoints is given by evaluating the center function on the Xs and Ys for the corresponding set of XY values in the pts parameter. The XError and YError are computed likewise, using the err function. This function can be useful for

(f func([]float64) (c, l, h float64), pts ...plotter.XYer)

Source from the content-addressed store, hash-verified

30// scatter points using a single point and error bars for
31// each element of the scatter.
32func NewErrorPoints(f func([]float64) (c, l, h float64), pts ...plotter.XYer) (*ErrorPoints, error) {
33
34 c := &ErrorPoints{
35 XYs: make(plotter.XYs, len(pts)),
36 XErrors: make(plotter.XErrors, len(pts)),
37 YErrors: make(plotter.YErrors, len(pts)),
38 }
39
40 for i, xy := range pts {
41 xs := make([]float64, xy.Len())
42 ys := make([]float64, xy.Len())
43 for j := range xy.Len() {
44 xs[j], ys[j] = xy.XY(j)
45 if err := plotter.CheckFloats(xs[j], ys[j]); err != nil {
46 return nil, err
47 }
48 }
49 c.XYs[i].X, c.XErrors[i].Low, c.XErrors[i].High = f(xs)
50 if err := plotter.CheckFloats(c.XYs[i].X, c.XErrors[i].Low, c.XErrors[i].High); err != nil {
51 return nil, err
52 }
53 c.XYs[i].Y, c.YErrors[i].Low, c.YErrors[i].High = f(ys)
54 if err := plotter.CheckFloats(c.XYs[i].Y, c.YErrors[i].Low, c.YErrors[i].High); err != nil {
55 return nil, err
56 }
57 }
58
59 return c, nil
60}
61
62// MeanAndConf95 returns the mean
63// and the magnitude of the 95% confidence

Callers 2

ExampleErrorPointsFunction · 0.92
Example_errpointsFunction · 0.92

Calls 3

CheckFloatsFunction · 0.92
LenMethod · 0.65
XYMethod · 0.65

Tested by 1

ExampleErrorPointsFunction · 0.74