median returns the median value from a sorted Values.
(vs Values)
| 179 | // median returns the median value from a |
| 180 | // sorted Values. |
| 181 | func median(vs Values) float64 { |
| 182 | if len(vs) == 1 { |
| 183 | return vs[0] |
| 184 | } |
| 185 | med := vs[len(vs)/2] |
| 186 | if len(vs)%2 == 0 { |
| 187 | med += vs[len(vs)/2-1] |
| 188 | med /= 2 |
| 189 | } |
| 190 | return med |
| 191 | } |
| 192 | |
| 193 | // Plot draws the BoxPlot on Canvas c and Plot plt. |
| 194 | func (b *BoxPlot) Plot(c draw.Canvas, plt *plot.Plot) { |