// Beta is equivalent to Alpha but controls the smoothing of the trend
// instead of the data.
355340
func (m *HoltWintersMovAvgModel) Beta(beta float64) *HoltWintersMovAvgModel {
	m.beta = &beta
	return m
}
110820
func (r *Regression) Coeff(i int) float64 {
	if len(r.coeff) == 0 {
		return 0
	}
	return r.coeff[i]
}
1039145
func (s *SortCommand) Alpha(b bool) *SortCommand {
	s.alpha = b
	return s
}
1020201
def down_alpha_beta(returns, factor_returns, **kwargs):
    
    return down(returns, factor_returns, function=alpha_beta_aligned, **kwargs)
721039
func (f Filter) DateBetween(start string, end string) Filter {
	f.Op = "betweenDate"
	f.Val = nil
	return f.Opt("startDate", []string{start}).Opt("endDate", []string{end})
}
145219
func BgRed(arg interface{}) Value {
	if val, ok := arg.(Value); ok {
		return val.BgRed()
	}
	return value{value: arg, color: RedBg}
}
273343
func Alpha(dest *Image, alpha int) {
	r := dest.Bounds()

	var a, x, y, i int
	for x = r.Min.X; x < r.Max.X; x++ {
		for y = r.Min.Y; y < r.Max.Y; y++ {
			i = dest.PixOffset(x, y)
			a = int(dest.Pix[i+3])
			dest.Pix[i+3] = uint8((a * alpha) / 100)
		}
	}
}
678898
func (lsf *LeastSquaresFunction) slope() float64 {
	if lsf.count < 2 {
		// Not enough points added.
		return math.NaN()
	}

	if math.Abs(lsf.sumXX) < 10*math.SmallestNonzeroFloat64 {
		// Not enough variation in X.
		return math.NaN()
	}
	return lsf.sumXY / lsf.sumXX
}
1326415
func blend(d, s uint8, alpha float64) uint8 {
	return uint8(float64(s)*alpha + float64(d)*(1-alpha))
}
892274
func (f Float64Data) Covariance(d Float64Data) (float64, error) {
	return Covariance(f, d)
}
950051
func (grng GammaGenerator) gamma(alpha, beta float64) float64 {
	var MAGIC_CONST float64 = 4 * math.Exp(-0.5) / math.Sqrt(2.0)
	if alpha > 1.0 {
		// Use R.C.H Cheng "The generation of Gamma variables with
		// non-integral shape parameters", Applied Statistics, (1977), 26, No. 1, p71-74

		ainv := math.Sqrt(2.0*alpha - 1.0)
		bbb := alpha - math.Log(4.0)
		ccc := alpha + ainv

		for {
			u1 := grng.uniform.Float64()
			if !(1e-7 < u1 && u1 < .9999999) {
				continue
			}
			u2 := 1.0 - grng.uniform.Float64()
			v := math.Log(u1/(1.0-u1)) / ainv
			x := alpha * math.Exp(v)
			z := u1 * u1 * u2
			r := bbb + ccc*v - x
			if r+MAGIC_CONST-4.5*z >= 0.0 || r >= math.Log(z) {
				return x * beta
			}
		}
	} else if alpha == 1.0 {
		u := grng.uniform.Float64()
		for u <= 1e-7 {
			u = grng.uniform.Float64()
		}
		return -math.Log(u) * beta
	} else { // alpha between 0.0 and 1.0 (exclusive)
		// Uses Algorithm of Statistical Computing - kennedy & Gentle
		var x float64
		for {
			u := grng.uniform.Float64()
			b := (math.E + alpha) / math.E
			p := b * u
			if p <= 1.0 {
				x = math.Pow(p, 1.0/alpha)
			} else {
				x = -math.Log((b - p) / alpha)
			}
			u1 := grng.uniform.Float64()
			if p > 1.0 {
				if u1 <= math.Pow(x, alpha-1.0) {
					break
				}
			} else if u1 <= math.Exp(-x) {
				break
			}
		}
		return x * beta
	}
}
518300
func analyticsFor(ss []string, cutoff int) []analytic {
	m := make(map[string]int)
	t := 0
	for _, s := range ss {
		m[s]++
		t++
	}

	l := make([]analytic, 0, len(m))
	for k, c := range m {
		l = append(l, analytic{
			Key:        k,
			Count:      c,
			Percentage: 100 * float64(c) / float64(t),
		})
	}

	sort.Sort(analyticList(l))

	if cutoff > 0 && len(l) > cutoff {
		c := 0
		for _, i := range l[cutoff:] {
			c += i.Count
		}
		l = append(l[:cutoff], analytic{
			Key:        "Others",
			Count:      c,
			Percentage: 100 * float64(c) / float64(t),
		})
	}

	return l
}
871199
func Granular(granularity int, changes []Change) []Change {
	if len(changes) == 0 {
		return changes
	}
	gap := 0
	for i := 1; i < len(changes); i++ {
		curr := changes[i]
		prev := changes[i-gap-1]
		// same as curr.B-(prev.B+prev.Ins); consistency is key
		if curr.A-(prev.A+prev.Del) <= granularity {
			// merge changes:
			curr = Change{
				A: prev.A, B: prev.B, // start at same spot
				Del: curr.A - prev.A + curr.Del, // from first to end of second
				Ins: curr.B - prev.B + curr.Ins, // from first to end of second
			}
			gap++
		}
		changes[i-gap] = curr
	}
	return changes[:len(changes)-gap]
}
404739
func (m *EWMAMovAvgModel) Alpha(alpha float64) *EWMAMovAvgModel {
	m.alpha = &alpha
	return m
}
1312215
func (s Samples) Less(i, j int) bool {
	switch {
	case s[i].Metric.Before(s[j].Metric):
		return true
	case s[j].Metric.Before(s[i].Metric):
		return false
	case s[i].Timestamp.Before(s[j].Timestamp):
		return true
	default:
		return false
	}
}
731602
func (n *Node) ChangesBetween(from, to api.Version) ([]state.Change, error) {
	n.stopMu.RLock()
	defer n.stopMu.RUnlock()

	if from.Index > to.Index {
		return nil, errors.New("versions are out of order")
	}

	if !n.IsMember() {
		return nil, ErrNoRaftMember
	}

	// never returns error
	last, _ := n.raftStore.LastIndex()

	if to.Index > last {
		return nil, errors.New("last version is out of bounds")
	}

	pbs, err := n.raftStore.Entries(from.Index+1, to.Index+1, math.MaxUint64)
	if err != nil {
		return nil, err
	}

	var changes []state.Change
	for _, pb := range pbs {
		if pb.Type != raftpb.EntryNormal || pb.Data == nil {
			continue
		}
		r := &api.InternalRaftRequest{}
		err := proto.Unmarshal(pb.Data, r)
		if err != nil {
			return nil, errors.Wrap(err, "error umarshalling internal raft request")
		}

		if r.Action != nil {
			changes = append(changes, state.Change{StoreActions: r.Action, Version: api.Version{Index: pb.Index}})
		}
	}

	return changes, nil
}
791269
func (s *i18nSorter) Less(i, j int) bool {

	iValue := strings.ToLower(s.getComparisonValueFunc(s.toBeSorted[i]))
	jValue := strings.ToLower(s.getComparisonValueFunc(s.toBeSorted[j]))

	// if it's a local sort, use the collator
	if s.collator != nil {
		return s.collator.CompareString(iValue, jValue) == -1
	}

	// for universal sorts, normalize the unicode to sort
	normalizer := norm.NFKD
	iValue = normalizer.String(iValue)
	jValue = normalizer.String(jValue)

	return bytes.Compare([]byte(iValue), []byte(jValue)) == -1
}