// CDF is the probability of getting int(k) or fewer successes in
// d.Draws draws with replacement from a population of size d.N that
// contains exactly d.K successes.
518931
func (d HypergeometicDist) CDF(k float64) float64 {
	// Based on Klotz, A Computational Approach to Statistics.
	ki := int(math.Floor(k))
	l, h := d.bounds()
	if ki < l {
		return 0
	} else if ki >= h {
		return 1
	}
	// Use symmetry to compute the smaller sum.
	flip := false
	if ki > (d.Draws+1)/(d.N+1)*(d.K+1) {
		flip = true
		ki = d.K - ki - 1
		d.Draws = d.N - d.Draws
	}
	p := d.pmf(ki) * d.sum(ki)
	if flip {
		p = 1 - p
	}
	return p
}
441659
func (x Vector) Ecdf() func(float64) float64 {
	y := x.Copy()

	y.Sort()
	n := len(y)

	empirical := func(q float64) float64 {
		i := 0
		for i < n {
			if q < y[i] {
				return float64(i) / float64(n)
			}
			i++
		}
		return 1.0
	}

	return empirical
}
352130
func (cdb *CDB) Get(key []byte) ([]byte, error) {
	hash := cdb.hash(key)

	table := cdb.index[hash&0xff]
	if table.length == 0 {
		return nil, nil
	}

	// Probe the given hash table, starting at the given slot.
	startingSlot := (hash >> 8) % table.length
	slot := startingSlot

	for {
		slotOffset := table.offset + (8 * slot)
		slotHash, offset, err := readTuple(cdb.reader, slotOffset)
		if err != nil {
			return nil, err
		}

		// An empty slot means the key doesn't exist.
		if slotHash == 0 {
			break
		} else if slotHash == hash {
			value, err := cdb.getValueAt(offset, key)
			if err != nil {
				return nil, err
			} else if value != nil {
				return value, nil
			}
		}

		slot = (slot + 1) % table.length
		if slot == startingSlot {
			break
		}
	}

	return nil, nil
}
1369388
func (u *Ugen) Absdif(val Input) Input {
	return binOpAbsdif(u.Rate, u, val, u.NumOutputs)
}
334716
func binOpAbsdif(rate int8, x, y Input, numOutputs int) Input {
	CheckRate(rate)
	return NewInput(BinOpUgenName, rate, BinOpAbsdif, numOutputs, x, y)
}
1284905
func Roundf(a, b float32) float32 {
	if b == 0 {
		return 0
	}
	var m, v float32

	for {
		if b*m <= a {
			if b*(m+1) > a {
				if math.Abs(float64(a-b*m)) < math.Abs(float64(a-b*(m+1))) {
					v = b * m
				} else {
					v = b * (m + 1)
				}
				break
			}
			m++
			continue
		}
		m--
		if b*m <= a {
			if math.Abs(float64(a-b*m)) < math.Abs(float64(a-b*(m+1))) {
				v = b * m
			} else {
				v = b * (m + 1)
			}
			break
		}
	}
	return v
}
772727
func betacf(x, a, b float64) float64 {
	const maxIterations = 200
	const epsilon = 3e-14

	raiseZero := func(z float64) float64 {
		if math.Abs(z) < math.SmallestNonzeroFloat64 {
			return math.SmallestNonzeroFloat64
		}
		return z
	}

	c := 1.0
	d := 1 / raiseZero(1-(a+b)*x/(a+1))
	h := d
	for m := 1; m <= maxIterations; m++ {
		mf := float64(m)

		// Even step of the recurrence.
		numer := mf * (b - mf) * x / ((a + 2*mf - 1) * (a + 2*mf))
		d = 1 / raiseZero(1+numer*d)
		c = raiseZero(1 + numer/c)
		h *= d * c

		// Odd step of the recurrence.
		numer = -(a + mf) * (a + b + mf) * x / ((a + 2*mf) * (a + 2*mf + 1))
		d = 1 / raiseZero(1+numer*d)
		c = raiseZero(1 + numer/c)
		hfac := d * c
		h *= hfac

		if math.Abs(hfac-1) < epsilon {
			return h
		}
	}
	panic("betainc: a or b too big; failed to converge")
}
154349
def cdf(x, df, loc=0.0, scale=1.0, gamma = 1.0):
        
        result = np.zeros(x.shape[0])
        result[x<0] = 2.0/(np.power(gamma,2) + 1.0)*ss.t.cdf(gamma*(x[x-loc < 0]-loc[x-loc < 0])/scale, df=df)
        result[x>=0] = 1.0/(np.power(gamma,2) + 1.0) + 2.0/((1.0/np.power(gamma,2)) + 1.0)*(ss.t.cdf((x[x-loc >= 0]-loc[x-loc >= 0])/(gamma*scale), df=df)-0.5)
        return result
1209311
public function cdf(int $k): float
    {
        $a = $this->a;
        $b = $this->b;

        if ($k < $a) {
            return 0;
        }
        if ($k > $b) {
            return 1;
        }

        $n = $b - $a + 1;

        return ($k - $a + 1) / $n;
    }
1006785
func Errorf(format string, a ...interface{}) error {
	return fmt.Errorf(format, wrap(a, false)...)
}
1039730
func (grng GeometricGenerator) Geometric(p float64) int64 {
	if !(0.0 <= p && p <= 1.0) {
		panic(fmt.Sprintf("Invalid probability p: %.2f", p))
	}
	return grng.geometric(p)
}
1034431
public static double cdf(double val, double k, double lambda, double theta) {
    return (val > theta) ? //
        (1.0 - FastMath.exp(-FastMath.pow((val - theta) / lambda, k))) //
        : val == val ? 0.0 : Double.NaN;
  }
684714
func Errorf(ref int, format string, i ...interface{}) error {
	return Error{
		Reference: ref,
		Err:       fmt.Sprintf(format, i...),
	}
}
1192766
func (s *ValidateService) Df(df string) *ValidateService {
	s.df = df
	return s
}
540929
func (c *Context) Uniform3f(location *js.Object, x, y, z float32) {
	c.Call("uniform3f", location, x, y, z)
}
784740
def cdf(self, x):
        
        t = 0
        N = float(self.n)

        if len(self) == 1:  # only one centroid
            return int(x >= self.C.min_key())

        for i, key in enumerate(self.C.keys()):
            c_i = self.C[key]
            if i == len(self) - 1:
                delta = (c_i.mean - self.C.prev_item(key)[1].mean) / 2.
            else:
                delta = (self.C.succ_item(key)[1].mean - c_i.mean) / 2.
            z = max(-1, (x - c_i.mean) / delta)

            if z < 1:
                return t / N + c_i.count / N * (z + 1) / 2

            t += c_i.count
        return 1
488759
func (proxier *Proxier) precomputeProbabilities(numberOfPrecomputed int) {
	if len(proxier.precomputedProbabilities) == 0 {
		proxier.precomputedProbabilities = append(proxier.precomputedProbabilities, "<bad value>")
	}
	for i := len(proxier.precomputedProbabilities); i <= numberOfPrecomputed; i++ {
		proxier.precomputedProbabilities = append(proxier.precomputedProbabilities, computeProbability(i))
	}
}