Owl_mathsSourceMaths: fundamental and advanced mathematical functions.
This module contains some basic and advanced mathematical operations. If you cannot find some function in this module, try Stats module.
Please refer to Scipy documentation.
add x y returns :math:`x + y`.
sub x y returns :math:`x - y`.
mul x y returns :math:`x * y`.
div x y returns :math:`x / y`.
fmod x y returns :math:`x % y`.
atan2 y x returns :math:`\arctan(y/x)`, accounting for the sign of the arguments; this is the angle to the vector :math:`(x, y)` counting from the x-axis.
abs x returns :math:`|x|`.
neg x returns :math:`-x`.
reci x returns :math:`1/x`.
floor x returns the largest integer :math:`\leq x`.
ceil x returns the smallest integer :math:`\geq x`.
round x rounds, towards the bigger integer when on the fence.
trunc x integer part.
sqr x square.
sqrt x square root.
pow x y returns :math:`x^y`.
exp x exponential.
exp2 x exponential.
exp10 x exponential.
expm1 x returns :math:`\exp(x) - 1` but more accurate for :math:`x \sim 0`.
log x natural logarithm
log2 x base-2 logarithm.
log10 x base-10 logarithm.
logn x base-n logarithm.
log1p x returns :math:`\log (x + 1)` but more accurate for :math:`x \sim 0`. Inverse of expm1.
logabs x returns :math:`\log(|x|)`.
sigmoid x returns the logistic sigmoid function :math:`1 / (1 + \exp(-x))`.
signum x returns the sign of :math:`x`: -1, 0 or 1.
Smoothed sign function.
softplus x returns :math:`\log(1 + \exp(x))`.
relu x returns :math:`\max(0, x)`.
sin x returns :math:`\sin(x)`.
cos x returns :math:`\cos(x)`.
tan x returns :math:`\tan(x)`.
cot x returns :math:`1/\tan(x)`.
sec x returns :math:`1/\cos(x)`.
csc x returns :math:`1/\sin(x)`.
asin x returns :math:`\arcsin(x)`.
acos x returns :math:`\arccos(x)`.
atan x returns :math:`\arctan(x)`.
Inverse function of cot.
Inverse function of sec.
Inverse function of csc.
Returns :math:`\sinh(x)`.
cosh x returns :math:`\cosh(x)`.
tanh x returns :math:`\tanh(x)`.
coth x returns :math:`\coth(x)`.
sech x returns :math:`1/\cosh(x)`.
csch x returns :math:`1/\sinh(x)`.
Inverse function of sinh.
Inverse function of cosh.
Inverse function of tanh.
Inverse function of coth.
Inverse function of sech.
Inverse function of csch.
sinc x returns :math:`\sin(x)/x` and :math:`1` for :math:`x=0`.
logsinh x returns :math:`\log(\sinh(x))` but handles large :math:`|x|`.
logcosh x returns :math:`\log(\cosh(x))` but handles large :math:`|x|`.
Sine of angle given in degrees.
Cosine of the angle given in degrees.
Tangent of angle given in degrees.
Cotangent of the angle given in degrees.
hypot x y returns :math:`\sqrtx^2 + y^2`.
xlogy(x, y) returns :math:`x \log(y)`.
xlog1py(x, y) returns :math:`x \log(y+1)`.
logit(x) returns :math:`\logp/(1-p)`.
expit(x) returns :math:`1/(1+\exp(-x))`.
log1mexp(x) returns :math:`log(1-exp(x))`.
log1pexp(x) returns :math:`log(1+exp(x))`.
Airy function airy x returns (Ai, Ai', Bi, Bi') evaluated at :math:`x`. Ai' is the derivative of Ai whilst Bi' is the derivative of Bi.
Bessel function of the first kind of order 0.
Bessel function of the first kind of order 1.
Bessel function of real order.
Bessel function of the second kind of order 0.
Bessel function of the second kind of order 1.
Bessel function of the second kind of real order.
Bessel function of the second kind of integer order.
Modified Bessel function of order 0.
Exponentially scaled modified Bessel function of order 0.
Modified Bessel function of order 1.
Exponentially scaled modified Bessel function of order 1.
Modified Bessel function of the first kind of real order.
Modified Bessel function of the second kind of order 0, :math:`K_0`.
Exponentially scaled modified Bessel function K of order 0.
Modified Bessel function of the second kind of order 1, :math:`K_1(x)`.
Exponentially scaled modified Bessel function K of order 1.
Jacobian Elliptic function ellipj u m returns (sn, cn, dn, phi).
ellipk m returns the complete elliptic integral of the first kind.
FIXME. Complete elliptic integral of the first kind around :math:`m = 1`.
ellipkinc phi m incomplete elliptic integral of the first kind.
ellipe m complete elliptic integral of the second kind.
ellipeinc phi m incomplete elliptic integral of the second kind.
gamma z returns the value of the Gamma function
.. math:: \Gamma(z) = \int_0^\infty x^z-1 e^
x
}
dx = (z - 1)! .
The gamma function is often referred to as the generalized factorial since :math:`z\ gamma(z) = \gamma(z+1)` and :math:`gamma(n+1) = n!` for natural number :math:`n`.
Reciprocal Gamma function.
Logarithm of the gamma function.
Incomplete gamma function.
Inverse function of gammainc.
Complemented incomplete gamma integral.
Inverse function of gammaincc.
The digamma function.
Beta function.
.. math:: \mathrmB(a, b) = \frac\Gamma(a) \Gamma(b)\Gamma(a+b)
Incomplete beta integral.
Inverse function of betainc.
Factorial function fact n calculates :math:`n!`.
Logarithm of factorial function log_fact n calculates :math:`\log n!`.
Double factorial function doublefact n calculates :math:`n!! = n(n-2)(n-4)\dots 2` or :math:`\dots 1`
Logarithm of double factorial function.
permutation n k returns the number :math:`n!/(n-k)!` of ordered subsets * of length :math:`k`, taken from a set of :math:`n` elements.
permutation_float is like permutation but deals with larger range.
combination n k returns the number :math:`n!/(k!(n-k)!)` of subsets of k elements of a set of n elements. This is the binomial coefficient :math:`\binomnk`
combination_float is like combination but can deal with a larger range.
log_combination n k returns the logarithm of :math:`\binomnk`.
Error function. :math:`\int_
\infty
}
^x \frac
\sqrt(2\pi) \exp(-(1/2) y^2) dy`
Complementary error function, :math:`\int^\infty_x \frac
\sqrt(2\pi) \exp(-(1/2) y^2) dy`
Scaled complementary error function, :math:`\exp(x^2) \mathrmrfc(x)`.
Inverse function of erf.
Inverse function of erfc.
Dawson’s integral.
Fresnel trigonometric integrals. fresnel x returns a tuple consisting of (Fresnel sin integral, Fresnel cos integral).
struve v x returns the value of the Struve function of order :math:`v` at :math:`x`. The Struve function is defined as,
.. math:: H_v(x) = (z/2)^
+ 1} \sum_{n=0}^\infty \frac{(-1)^n (z/2)^{2n}}{\Gamma(n + \frac{3}{2}) \Gamma(n + v + \frac{3}{2})},
where :math:`\Gamma` is the gamma function. :math:`x` must be positive unless :math:`v` is an integer
Exponential integral :math:`E_n`.
Hyperbolic sine and cosine integrals, shichi x returns * :math:`(\mathrmshi, \mathrmchi)``.
Hyperbolic sine integral.
Hyperbolic cosine integral.
Sine and cosine integrals, sici x returns :math:`(\mathrmsi, \mathrmci)`.
Sine integral.
Cosine integral.
zeta x q returns the Hurwitz zeta function :math:`\zeta(x, q)`, which reduces to the Riemann zeta function :math:`\zeta(x)` when :math:`q=1`.
Riemann zeta function minus 1.
Binomial distribution cumulative distribution function.
bdtr k n p calculates the sum of the terms :math:`0` through :math:`k` of the Binomial probability density.
.. math:: \mathrmdtr(k, n, p) = \sum_j=0^k {n\choosej
}
p^j (1-p)^n-j
Parameters: * k: Number of successes. * n: Number of events. * p: Probability of success in a single event.
Returns: * Probability of :math:`k` or fewer successes in :math:`n` independent events with success probability :math:`p`.
Binomial distribution survival function.
bdtrc k n p calculates the sum of the terms :math:`k + 1` through :math:`n` of the binomial probability density,
.. math:: \mathrmdtrc(k, n, p) = \sum_j=k+1^n {n\choosej
}
p^j (1-p)^n-j
Inverse function to bdtr with respect to :math:`p`.
Finds the event probability :math:`p` such that the sum of the terms 0 through :math:`k` of the binomial probability density is equal to the given cumulative probability :math:`y`.
Cumulative density function of the beta distribution.
btdtr a b x returns the integral from 0 to :math:`x` of the beta probability density function,
.. math:: I = \int_0^x \frac\Gamma(a + b)\Gamma(a)\Gamma(b) t^a-1 (1-t)^-1\,dt
where :math:`\Gamma` is the gamma function.
Parameters: * a: Shape parameter (:math:`a > 0`). * b: Shape parameter (:math:`a > 0`). * x: Upper limit of integration, in :math:`0, 1`.
Returns: * Cumulative density function of the beta distribution with :math:`a` and :math:`b` at :math:`x`.
The :math:`p`-th quantile of the Beta distribution.
This function is the inverse of the beta cumulative distribution function, btdtr, returning the value of :math:`x` for which :math:`\mathrmtdtr(a, b, x) = p`,
.. math:: p = \int_0^x \frac\Gamma(a + b)\Gamma(a)\Gamma(b) t^a-1 (1-t)^-1\,dt
where :math:`\Gamma` is the gamma function.
Parameters: * a: Shape parameter (:math:`a > 0`). * b: Shape parameter (:math:`a > 0`). * x: Cumulative probability, in :math:`0, 1`.
Returns: * The quantile corresponding to :math:`p`.
is_nan x returns true exactly if x is nan.
is_inf x returns true exactly if x is infinity or neg_infinity.
is_normal x returns true if x is a normal float number.
is_nan x returns true if x is subnormal float number.
is_odd x returns true exactly if x is odd.
is_even x returns true exactly if x is even.
is_pow2 x return true exactly if x is an integer power of 2, e.g. 32, 64, etc.
same_sign x y returns true if x and y have the same sign, otherwise it returns false. Positive and negative zeros are special cases and always returns true.
is_simplex x checks whether the vector :math:`x` lies on a simplex. In other words, :math:`\sum_i^K x_i = 1` and :math:`x_i \ge 0, \forall i \in 1,K`, where :math:`K` is the dimension of :math:`x`.
is_sqr x checks if x is the square of an integer.
mulmod a b m computes (a*b) mod m.
powmod a b m computes (a^b) mod m.
is_prime x returns true if x is a prime number. The function is deterministic for all numbers representable by an int. The function uses the Rabin–Miller primality test.
fermat_fact x performs Fermat factorisation over x, i.e. into two roughly equal factors. x must be an odd number.
nextafter from to returns the next representable double precision value of from in the direction of to. If from equals to, this value is returned.
nextafter from to returns the next representable single precision value of from in the direction of to. If from equals to, this value is returned.