 maths

package maths

Linear Supertypes
AnyRef, Any
Ordering
1. Alphabetic
2. By inheritance
Inherited
1. maths
2. AnyRef
3. Any
1. Hide All
2. Show all
Visibility
1. Public
2. All

Value Members

6. def almostEquals(d1: Double, d2: Double, epsilon: Double = 0.000001): Boolean

Numbers that are closer than this are considered equal

10. def entropy(p: Array[Double]): Double

Return the entropy of the normalized distribution p.

Return the entropy of the normalized distribution p. The log is w.r.t. base 2.

13. def jensenShannonDivergence(p1: Array[Double], p2: Array[Double]): Double

Returns the Jensen-Shannon divergence.

14. def klDivergence(p1: Array[Double], p2: Array[Double]): Double

Returns the KL divergence, K(p1 || p2).

Returns the KL divergence, K(p1 || p2). The log is w.r.t. base 2.

*Note*: If any value in p2 is 0.0 then the KL-divergence is infinite.

17. def logBinom(x: Int, n: Int, p: Double): Double

Computes p(x;n,p) where x~B(n,p)

21. def nextBeta(alpha: Double, beta: Double)(implicit r: Random): Double

Return a random double drawn from a Beta distribution with mean a/(a+b) and variance ab/((a+b+1)(a+b)^2).

22. def nextBitSet(size: Int, p: Double)(implicit r: Random): BitSet

Return a random BitSet with "size" bits, each having probability p of being true.

23. def nextBoolean(p: Double)(implicit r: Random): Boolean

Return a random boolean, with probability p of being true.

24. def nextBoolean(implicit r: Random): Boolean

Return a random boolean, equally likely to be true or false.

25. def nextChiSq(df: Int, lambda: Double)(implicit r: Random): Double

Return a random double drawn from an Chi-squared distribution with mean df+lambda and variance 2*df.

26. def nextChiSq(df: Int)(implicit r: Random): Double

Return a random double drawn from an Chi-squared distribution with mean df and variance 2*df.

27. def nextChiSq(implicit r: Random): Double

Return a random double drawn from an Chi-squarted distribution with mean 1 and variance 2.

Return a random double drawn from an Chi-squarted distribution with mean 1 and variance 2. Equivalent to nextChiSq(1)

28. def nextDiscrete(a: Array[Double], sum: Double)(implicit r: Random): Int

draw a single sample from (unnormalized) multinomial "a", with normalizing factor "sum".

29. def nextDiscrete(a: Array[Double])(implicit r: Random): Int

Draw a single sample from multinomial "a".

Draw a single sample from multinomial "a". Assumes that the elements of "a" already sum to 1.0.

30. def nextExp(beta: Double, lambda: Double)(implicit r: Random): Double

Return a random double drawn from an Exponential distribution with mean beta+lambda and variance beta^2.

31. def nextExp(beta: Double)(implicit r: Random): Double

Return a random double drawn from an Exponential distribution with mean beta and variance beta^2.

32. def nextExp(implicit r: Random): Double

Return a random double drawn from an Exponential distribution with mean 1 and variance 1.

33. def nextGamma(alpha: Double, beta: Double, lambda: Double)(implicit r: Random): Double

Return a random double drawn from a Gamma distribution with mean alpha*beta+lamba and variance alpha*beta^2.

34. def nextGamma(alpha: Double, beta: Double)(implicit r: Random): Double

Return a random double drawn from a Gamma distribution with mean alpha*beta and variance alpha*beta^2.

35. def nextGamma(alpha: Double)(implicit r: Random): Double

Return a random double drawn from a Gamma distribution with mean alpha and variance 1.

Return a random double drawn from a Gamma distribution with mean alpha and variance 1.0.

36. def nextGamma(implicit r: Random): Double

Return a random double drawn from a Gamma distribution with mean 1.

Return a random double drawn from a Gamma distribution with mean 1.0 and variance 1.0.

37. def nextGaussian(mean: Double, s2: Double)(implicit r: Random): Double

Return a random double drawn from a Gaussian distribution with mean m and variance s2.

38. def nextGaussian(implicit r: Random): Double

Return a random double drawn from a Gaussian distribution with mean 0 and variance 1.

39. def nextPoisson(implicit r: Random): Double

Return nextPoisson(1).

40. def nextPoisson(lambda: Double)(implicit r: Random): Double

Return random integer from Poission with parameter lambda.

Return random integer from Poission with parameter lambda. The mean of this distribution is lambda. The variance is lambda.

41. final def nextUniform(implicit r: Random): Double

Return a random double in the range 0 to 1, inclusive, uniformly sampled from that range.

Return a random double in the range 0 to 1, inclusive, uniformly sampled from that range. The mean of this distribution is 0.5. The variance is 1/12.

Annotations
@inline()

44. def pbinom(x: Int, n: Int, p: Double): Double

Vastly inefficient O(x) method to compute cdf of B(n,p)

48. def sampleVariance(ds: DoubleSeq, mean: Double): Double

Returns the unbiased sample variance.

Returns the unbiased sample variance. See http://en.wikipedia.org/wiki/Variance#Population_variance_and_sample_variance

53. def sumLogProb(a: Double, b: Double): Double

Returns the sum of two doubles expressed in log space, that is,

sumLogProb = log (e^a + e^b)
= log e^a(1 + e^(b-a))
= a + log (1 + e^(b-a))

Returns the sum of two doubles expressed in log space, that is,

sumLogProb = log (e^a + e^b)
= log e^a(1 + e^(b-a))
= a + log (1 + e^(b-a))

By exponentiating b-a, we obtain better numerical precision than we would if we calculated e^a or e^b directly.