// WeightValue returns the weight value for this edge, normalizing if a
// divisor is available.
10181
func (e *Edge) WeightValue() int64 {
	if e.WeightDiv == 0 {
		return e.Weight
	}
	return e.Weight / e.WeightDiv
}
1115645
func (m *WeightedCluster_ClusterWeight) Validate() error {
	if m == nil {
		return nil
	}

	if len(m.GetName()) < 1 {
		return WeightedCluster_ClusterWeightValidationError{
			field:  "Name",
			reason: "value length must be at least 1 bytes",
		}
	}

	if wrapper := m.GetWeight(); wrapper != nil {

		if wrapper.GetValue() < 1 {
			return WeightedCluster_ClusterWeightValidationError{
				field:  "Weight",
				reason: "value must be greater than or equal to 1",
			}
		}

	}

	{
		tmp := m.GetMetadataMatch()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return WeightedCluster_ClusterWeightValidationError{
					field:  "MetadataMatch",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	return nil
}
1041356
func Value(name string, value float64, unit string) metric_sender.ValueChainer {
	if metricSender == nil {
		return nil
	}
	return metricSender.Value(name, value, unit)
}
1207370
func (l WorkItemLink) EqualValue(u convert.Equaler) bool {
	other, ok := u.(WorkItemLink)
	if !ok {
		return false
	}
	l.Version = other.Version
	l.Lifecycle = other.Lifecycle
	return l.Equal(u)
}
1303773
func (v *variable) floatValue() float64 {
	f, err := strconv.ParseFloat(v.value, 64)
	if err != nil {
		panic("unexpected value " + v.value + " for float ")
	}
	return f
}
51784
func (s Slice) ValueAt(index ValueLength) (Slice, error) {
	if !s.IsObject() {
		return nil, InvalidTypeError{"Expecting type Object"}
	}

	key, err := s.getNthKey(index, false)
	if err != nil {
		return nil, WithStack(err)
	}
	byteSize, err := key.ByteSize()
	if err != nil {
		return nil, WithStack(err)
	}
	return Slice(key[byteSize:]), nil
}
1037885
func (fn ScriptFunction) Weight(weight float64) ScriptFunction {
	fn.weight = &weight
	return fn
}
704701
func IsValue(node Expr) bool {
	switch v := node.(type) {
	case *SQLVal:
		switch v.Type {
		case StrVal, HexVal, IntVal, ValArg:
			return true
		}
	}
	return false
}
531006
func (a *AlgorithmChain) WeightingRelation(
	word1ID int,
	word2ID int,
	rank *Rank,
) float32 {
	relationQty := rank.Relation.Node[word1ID][word2ID].Qty
	word1Qty := rank.Words[word1ID].Qty
	word2Qty := rank.Words[word2ID].Qty

	qDiff := float32(math.Abs(float64(word1Qty)-float64(word2Qty))) / 100
	weight := float32(relationQty) + qDiff

	return weight
}
239159
func (w *weightedRandomSelect) setWeight(item wrsItem, weight int64) {
	idx, ok := w.idx[item]
	if ok {
		w.root.setWeight(idx, weight)
		if weight == 0 {
			delete(w.idx, item)
		}
	} else {
		if weight != 0 {
			if w.root.itemCnt == w.root.maxItems {
				// add a new level
				newRoot := &wrsNode{sumWeight: w.root.sumWeight, itemCnt: w.root.itemCnt, level: w.root.level + 1, maxItems: w.root.maxItems * wrsBranches}
				newRoot.items[0] = w.root
				newRoot.weights[0] = w.root.sumWeight
				w.root = newRoot
			}
			w.idx[item] = w.root.insert(item, weight)
		}
	}
}
296489
func (a Anomalyzer) getWeight(name string, prob float64) float64 {
	weight := 0.5

	dynamicWeights := []string{"magnitude", "fence"}
	// If either the magnitude and fence methods don't have any
	// probability to contribute, we don't want to hear about it.
	// If they do, we upweight them substantially.
	if exists(name, dynamicWeights) {
		if prob > 0.8 {
			weight = 5.0
		} else {
			weight = 0.5
		}
	}

	return weight
}
559176
func IntegerValue(value, sum float64) (s string) {
	return fmt.Sprintf("%d", int64(value+0.5))
}
179310
func (p Space) EqualValue(u convert.Equaler) bool {
	other, ok := u.(Space)
	if !ok {
		return false
	}
	p.Version = other.Version
	p.Lifecycle = other.Lifecycle
	return p.Equal(u)
}
144665
func (t EnumType) EqualValue(u convert.Equaler) bool {
	return t.Equal(u)
}
4563
func (s Sample) Weight() float64 {
	if s.Weights == nil {
		return float64(len(s.Xs))
	}
	return vec.Sum(s.Weights)
}
720620
func (fn *ExponentialDecayFunction) Weight(weight float64) *ExponentialDecayFunction {
	fn.weight = &weight
	return fn
}
478467
func boundedWeightedAverage(x1 float64, w1 float64, x2 float64, w2 float64) float64 {
	if x1 > x2 {
		x1, x2, w1, w2 = x2, x1, w2, w1
	}
	result := (x1*w1 + x2*w2) / (w1 + w2)
	return math.Max(x1, math.Min(result, x2))
}