You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: measurement.go
    path of file: ./repos/kubernetes/vendor/github.com/onsi/gomega/gmeasure
    
    the code of the file until where you have to start completion: package gmeasure

import (
	"fmt"
	"math"
	"sort"
	"time"

	"github.com/onsi/gomega/gmeasure/table"
)

type MeasurementType uint

const (
	MeasurementTypeInvalid MeasurementType = iota
	MeasurementTypeNote
	MeasurementTypeDuration
	MeasurementTypeValue
)

var letEnumSupport = newEnumSupport(map[uint]string{uint(MeasurementTypeInvalid): "INVALID LOG ENTRY TYPE", uint(MeasurementTypeNote): "Note", uint(MeasurementTypeDuration): "Duration", uint(MeasurementTypeValue): "Value"})

func (s MeasurementType) String() string { return letEnumSupport.String(uint(s)) }
func (s *MeasurementType) UnmarshalJSON(b []byte) error {
	out, err := letEnumSupport.UnmarshJS
    
func (m Measurement) Stats() Stats {
	if m.Type == MeasurementTypeInvalid || m.Type == MeasurementTypeNote {
		return Stats{}
	}

	out := Stats{
		ExperimentName:  m.ExperimentName,
		MeasurementName: m.Name,
		Style:           m.Style,
		Units:           m.Units,
		PrecisionBundle: m.PrecisionBundle,
	}

	switch m.Type {
	case MeasurementTypeValue:
		out.Type = StatsTypeValue
		out.N = len(m.Values)
		if out.N == 0 {
			return out
		}
		indices, sum := make([]int, len(m.Values)), 0.0
		for idx, v := range m.Values {
			indices[idx] = idx
			sum += v
		}
		sort.Slice(indices, func(i, j int) bool {
			return m.Values[indices[i]] < m.Values[indices[j]]
		})
		out.ValueBundle = map[Stat]float64{
			StatMin:    m.Values[indices[0]],
			StatMax:    m.Values[indices[out.N-1]],
			StatMean:   sum / float64(out.N),
			StatStdDev: 0.0,
		}
		out.AnnotationBundle = map[Stat]string{
			StatMin: m.Annotations[indices[0]],
			StatMax: m.Annotations[indices[out.N-1]],
		}

		if out.N%2 == 0 {
			out.ValueBundle[StatMedian] = (m.Values[indices[out.N/2]] + m.Values[indices[out.N/2-1]]) / 2.0
		} else {
			out.ValueBundle[StatMedian] = m.Values[indices[(out.N-1)/2]]
		}

		for _, v := range m.Values {
			out.ValueBundle[StatStdDev] += (v - out.ValueBundle[StatMean]) * (v - out.ValueBundle[StatMean])
		}
		out.ValueBundle[StatStdDev] = math.Sqrt(out.ValueBundle[StatStdDev] / float64(out.N))
	case MeasurementTypeDuration:
		out.Type = StatsTypeDuration
		out.N = len(m.Durations)
		if out.N == 0 {
			return out
		}
		indices, sum := make([]int, len(m.Durations)), time.Duration(0)
		for idx, v := range m.Durations {
			indices[idx] = idx
			sum += v
		}
		sort.Slice(indices, func(i, j int) bool {
			return m.Durations[indices[i]] < m.Durations[indices[j]]
		})
		out.DurationBundle = map[Stat]time.Duration{
			StatMin:  m.Durations[indices[0]],
			StatMax:  m.Durations[indices[out.N-1]],
			StatMean: sum / time.Duration(out.N),
		}
		out.AnnotationBundle = map[Stat]string{
			StatMin: m.Annotations[indices[0]],
			StatMax: m.Annotations[indices[out.N-1]],
		}

		if out.N%2 == 0 {
			out.DurationBundle[StatMedian] = (m.Durations[indices[out.N/2]] + m.Durations[indices[out.N/2-1]]) / 2
		} else {
			out.DurationBundle[StatMedian] = m.Durations[indices[(out.N-1)/2]]
		}
		stdDev := 0.0
		for _, v := range m.Durations {
			stdDev += float64(v-out.DurationBundle[StatMean]) * float64(v-out.DurationBundle[StatMean])
		}
		out.DurationBundle[StatStdDev] = time.Duration(math.Sqrt(stdDev / float64(out.N)))
	}

	return out
}