/* Statistic Functions */
// Beta - Beta
15645
func Beta(inReal0 []float64, inReal1 []float64, inTimePeriod int) []float64 {

	outReal := make([]float64, len(inReal0))

	x := 0.0
	y := 0.0
	sSS := 0.0
	sXY := 0.0
	sX := 0.0
	sY := 0.0
	tmpReal := 0.0
	n := 0.0
	nbInitialElementNeeded := inTimePeriod
	startIdx := nbInitialElementNeeded
	trailingIdx := startIdx - nbInitialElementNeeded
	trailingLastPriceX := inReal0[trailingIdx]
	lastPriceX := trailingLastPriceX
	trailingLastPriceY := inReal1[trailingIdx]
	lastPriceY := trailingLastPriceY
	trailingIdx++
	i := trailingIdx
	for i < startIdx {
		tmpReal := inReal0[i]
		x := 0.0
		if !((-0.00000000000001 < lastPriceX) && (lastPriceX < 0.00000000000001)) {
			x = (tmpReal - lastPriceX) / lastPriceX
		}
		lastPriceX = tmpReal
		tmpReal = inReal1[i]
		i++
		y := 0.0
		if !((-0.00000000000001 < lastPriceY) && (lastPriceY < 0.00000000000001)) {
			y = (tmpReal - lastPriceY) / lastPriceY
		}
		lastPriceY = tmpReal
		sSS += x * x
		sXY += x * y
		sX += x
		sY += y
	}
	outIdx := inTimePeriod
	n = float64(inTimePeriod)
	for ok := true; ok; {
		tmpReal = inReal0[i]
		if !((-0.00000000000001 < lastPriceX) && (lastPriceX < 0.00000000000001)) {
			x = (tmpReal - lastPriceX) / lastPriceX
		} else {
			x = 0.0
		}
		lastPriceX = tmpReal
		tmpReal = inReal1[i]
		i++
		if !((-0.00000000000001 < lastPriceY) && (lastPriceY < 0.00000000000001)) {
			y = (tmpReal - lastPriceY) / lastPriceY
		} else {
			y = 0.0
		}
		lastPriceY = tmpReal
		sSS += x * x
		sXY += x * y
		sX += x
		sY += y
		tmpReal = inReal0[trailingIdx]
		if !(((-(0.00000000000001)) < trailingLastPriceX) && (trailingLastPriceX < (0.00000000000001))) {
			x = (tmpReal - trailingLastPriceX) / trailingLastPriceX
		} else {
			x = 0.0
		}
		trailingLastPriceX = tmpReal
		tmpReal = inReal1[trailingIdx]
		trailingIdx++
		if !(((-(0.00000000000001)) < trailingLastPriceY) && (trailingLastPriceY < (0.00000000000001))) {
			y = (tmpReal - trailingLastPriceY) / trailingLastPriceY
		} else {
			y = 0.0
		}
		trailingLastPriceY = tmpReal
		tmpReal = (n * sSS) - (sX * sX)
		if !(((-(0.00000000000001)) < tmpReal) && (tmpReal < (0.00000000000001))) {
			outReal[outIdx] = ((n * sXY) - (sX * sY)) / tmpReal
		} else {
			outReal[outIdx] = 0.0
		}
		outIdx++
		sSS -= x * x
		sXY -= x * y
		sX -= x
		sY -= y
		ok = i < len(inReal0)
	}

	return outReal
}
544895
func (rb *Bitmap) Stats() Statistics {
	stats := Statistics{}
	stats.Containers = uint64(len(rb.highlowcontainer.containers))
	for _, c := range rb.highlowcontainer.containers {
		stats.Cardinality += uint64(c.getCardinality())

		switch c.(type) {
		case *arrayContainer:
			stats.ArrayContainers++
			stats.ArrayContainerBytes += uint64(c.getSizeInBytes())
			stats.ArrayContainerValues += uint64(c.getCardinality())
		case *bitmapContainer:
			stats.BitmapContainers++
			stats.BitmapContainerBytes += uint64(c.getSizeInBytes())
			stats.BitmapContainerValues += uint64(c.getCardinality())
		case *runContainer16:
			stats.RunContainers++
			stats.RunContainerBytes += uint64(c.getSizeInBytes())
			stats.RunContainerValues += uint64(c.getCardinality())
		}
	}
	return stats
}
1071578
func Function(buffer Buffer, event *cue.Event) {
	if len(event.Frames) == 0 {
		buffer.AppendString(cue.UnknownFunction)
		return
	}
	buffer.AppendString(event.Frames[0].Function)
}
403764
func (p *Plot) Stat(stats ...Stat) *Plot {
	data := p.Data()
	for _, stat := range stats {
		data = stat.F(data)
	}
	return p.SetData(data)
}
247121
func builtin_min(args ...Value) (Value, error) {
	if len(args) == 0 {
		return nilValue, fmt.Errorf("missing arguments for function `min`")
	}
	x := args[0]
	for i, size := 1, len(args); i < size; i++ {
		lt, err := args[i].Lt(x)
		if err != nil {
			return Zero(), err
		}
		if lt.Bool() {
			x = args[i]
		}
	}
	return x, nil
}
1250449
func (this *Beanstalkd) StatsTube(tube string) (map[string]string, error) {
	e := this.send("stats-tube %s\r\n", tube)
	if e != nil {
		return nil, e
	}
	return this.handleMapResponse()
}
1286929
double betaFunction(List<Double> x, int type) {
    double beta;
    beta = 0;
    int dim = x.size();

    if (dim == 0) {
      beta = 0;
    }

    if (type == 1) {
      beta = 0;
      for (int i = 0; i < dim; i++) {
        beta += x.get(i) * x.get(i);
      }
      beta = 2.0 * beta / dim;
    }

    if (type == 2) {
      beta = 0;
      for (int i = 0; i < dim; i++) {
        beta += Math.sqrt(i + 1) * x.get(i) * x.get(i);
      }
      beta = 2.0 * beta / dim;
    }

    if (type == 3) {
      double sum = 0, xx;
      for (int i = 0; i < dim; i++) {
        xx = 2 * x.get(i);
        sum += (xx * xx - Math.cos(4 * Math.PI * xx) + 1);
      }
      beta = 2.0 * sum / dim;
    }

    if (type == 4) {
      double sum = 0, prod = 1, xx;
      for (int i = 0; i < dim; i++) {
        xx = 2 * x.get(i);
        sum += xx * xx;
        prod *= Math.cos(10 * Math.PI * xx / Math.sqrt(i + 1));
      }
      beta = 2.0 * (sum - 2 * prod + 2) / dim;
    }

    return beta;
  }
863139
func Beta(real0, real1 []float64, timePeriod int32) []float64 {
	var outBegIdx C.int
	var outNBElement C.int
	outReal := make([]float64, len(real0))
	C.TA_BETA(0, C.int(len(real0)-1), (*C.double)(unsafe.Pointer(&real0[0])), (*C.double)(unsafe.Pointer(&real1[0])), C.int(timePeriod), &outBegIdx, &outNBElement, (*C.double)(unsafe.Pointer(&outReal[0])))
	return outReal[:outNBElement]
}
483285
func (_m *Statter) NewSubStatter(_a0 string) statsd.SubStatter {
	ret := _m.Called(_a0)

	var r0 statsd.SubStatter
	if rf, ok := ret.Get(0).(func(string) statsd.SubStatter); ok {
		r0 = rf(_a0)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(statsd.SubStatter)
		}
	}

	return r0
}
933030
func AppendStatsAggregate(a, b StatsAggregate) (aggregate StatsAggregate) {
	if (a.Count == 0) {
		return b
	}

	if (b.Count == 0) {
		return a
	}

	aggregate.Average = ( (a.Average * float64(a.Count)) + (b.Average * float64(b.Count)) ) / float64(a.Count + b.Count)
	aggregate.Min     = math.Min(a.Min, b.Min)
	aggregate.Max     = math.Max(a.Max, b.Max)
	aggregate.Count   = a.Count + b.Count
	return
}
1373183
func main() {
	statikFS, err := fs.New()
	if err != nil {
		log.Fatal(err)
	}

	http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(statikFS)))
	http.ListenAndServe(":8080", nil)
}
94393
func NewStat() *Stat {
	s := &Stat{}
	runtime.SetFinalizer(s, (*Stat).free)

	initDone := make(chan bool)
	s.exitMessage = make(chan bool)

	C.sg_init(1)

	go func() {
		// We need some function calls to be performed on the same thread
		// Those for which statgrab is using a thread local
		runtime.LockOSThread()
		defer runtime.UnlockOSThread()

		// Throw away the first reading as thats averaged over the machines uptime
		C.sg_get_cpu_stats_diff(nil)
		C.sg_get_network_io_stats_diff(nil)
		C.sg_get_page_stats_diff(nil)
		C.sg_get_disk_io_stats_diff(nil)

		initDone <- true

		for {
			select {
			case <-s.exitMessage:
				return
			case f := <-mainfunc:
				f()
			}
		}

	}()

	<-initDone

	return s
}
731105
func (it *LinksTo) Stats() graph.IteratorStats {
	subitStats := it.primaryIt.Stats()
	// TODO(barakmich): These should really come from the quadstore itself
	checkConstant := int64(1)
	nextConstant := int64(2)
	st := graph.IteratorStats{
		NextCost:     nextConstant + subitStats.NextCost,
		ContainsCost: checkConstant + subitStats.ContainsCost,
		Next:         it.runstats.Next,
		Contains:     it.runstats.Contains,
		ContainsNext: it.runstats.ContainsNext,
	}
	st.Size, st.ExactSize = it.Size()
	return st
}
1201159
func (mc *Connection) Stats(argument string) (result []byte, err error) {
	defer handleError(&err)
	mc.setDeadline()
	if argument == "" {
		mc.writestrings("stats\r\n")
	} else {
		mc.writestrings("stats ", argument, "\r\n")
	}
	mc.flush()
	for {
		l := mc.readline()
		if strings.HasPrefix(l, "END") {
			break
		}
		if strings.Contains(l, "ERROR") {
			return nil, NewError(l)
		}
		result = append(result, l...)
		result = append(result, '\n')
	}
	return result, err
}
260617
func _() {
	var _ Event = (*Absolute)(nil)        // assert *Absolute implements Event
	var _ Event = (*FAbsolute)(nil)       // assert *FAbsolute implements Event
	var _ Event = (*Gauge)(nil)           // assert *Gauge implements Event
	var _ Event = (*FGauge)(nil)          // assert *FGauge implements Event
	var _ Event = (*GaugeDelta)(nil)      // assert *GaugeDelta implements Event
	var _ Event = (*FGaugeDelta)(nil)     // assert *FGaugeDelta implements Event
	var _ Event = (*Increment)(nil)       // assert *Increment implements Event
	var _ Event = (*PrecisionTiming)(nil) // assert *PrecisionTiming implements Event
	var _ Event = (*Timing)(nil)          // assert *Timing implements Event
	var _ Event = (*Total)(nil)           // assert *Total implements Event
}
942843
func functions(t *cc.TranslationUnit) ([]bg.Declaration, error) {
	filter := func(d *cc.Declarator) bool {
		if d.Type.Kind() != cc.Function {
			return false
		}
		return true
	}
	return bg.Get(t, filter)
}
466200
func main() {
	env, err := plugins.NewEnvironment()
	env.RespondAndExitIfError(err)

	var stats *statistics.DocumentStatistics

	for _, model := range env.Request.Models {
		switch model.TypeUrl {
		case "openapi.v2.Document":
			documentv2 := &openapiv2.Document{}
			err = proto.Unmarshal(model.Value, documentv2)
			if err == nil {
				// Analyze the API document.
				stats = statistics.NewDocumentStatistics(env.Request.SourceName, documentv2)
			}
		case "openapi.v3.Document":
			documentv3 := &openapiv3.Document{}
			err = proto.Unmarshal(model.Value, documentv3)
			if err == nil {
				// Analyze the API document.
				stats = statistics.NewDocumentStatisticsV3(env.Request.SourceName, documentv3)
			}
		}
	}

	if stats != nil {
		// Return the analysis results with an appropriate filename.
		// Results are in files named "summary.json" in the same relative
		// locations as the description source files.
		file := &plugins.File{}
		file.Name = strings.Replace(stats.Name, path.Base(stats.Name), "summary.json", -1)
		file.Data, err = json.MarshalIndent(stats, "", "  ")
		file.Data = append(file.Data, []byte("\n")...)
		env.RespondAndExitIfError(err)
		env.Response.Files = append(env.Response.Files, file)
	}

	env.RespondAndExit()
}