tfspecial.i0 (x)

Computes the modified Bessel function of order zero. Defined as: i0(x)=J0(ix)=m=01m!Γ(m+1)(x2)2m \mathrm{i0}(x) = J_0(i x) = \sum_{m=0}^\infty \frac{1}{m! \Gamma(m+1)} \left(\frac{x}{2}\right)^{2m}

const x = tf.tensor1d([0, 1, 2, 3, 4]);

tfspecial.i0(x).print();

Parameters

tfspecial.i1 (x)

Computes the modified Bessel function of order one. Defined as: i1(x)=J1(ix)=m=01m!Γ(m+2)(x2)2m+1 \mathrm{i1}(x) = J_1(i x) = \sum_{m=0}^\infty \frac{1}{m! \Gamma(m+2)} \left(\frac{x}{2}\right)^{2m+1}

const x = tf.tensor1d([0, 1, 2, 3, 4]);

tfspecial.i1(x).print();

Parameters

tfspecial.i0e (x)

Computes the modified Bessel function of order zero, exponentially scaled. Defined as: i0e(x)=exJ0(ix)=exm=01m!Γ(m+1)(x2)2m \mathrm{i0e}(x) = \mathrm{e}^{-|x|} J_0(i x) = \mathrm{e}^{-|x|} \sum_{m=0}^\infty \frac{1}{m! \Gamma(m+1)} \left(\frac{x}{2}\right)^{2m}

const x = tf.tensor1d([0, 1, 2, 3, 4]);

tfspecial.i0e(x).print();

Parameters

tfspecial.i1e (x)

Computes the modified Bessel function of order one, exponentially scaled. Defined as: i1e(x)=exJ1(ix)=exm=01m!Γ(m+2)(x2)2m+1 \mathrm{i1e}(x) = \mathrm{e}^{-|x|} J_1(i x) = \mathrm{e}^{-|x|} \sum_{m=0}^\infty \frac{1}{m! \Gamma(m+2)} \left(\frac{x}{2}\right)^{2m+1}

const x = tf.tensor1d([0, 1, 2, 3, 4]);

tfspecial.i0e(x).print();

Parameters

tfspecial.lbeta (x)

Computes the ln(B(x))\ln(|\Beta(\mathbf{x})|), where B(x)\Beta(\mathbf{x}) is the multivariate beta function and xx is the vector along the last dimention. Defined as: lbeta(x)=ln(B(x))B(x)=iΓ(xi)Γ(ixi) \begin{aligned} \mathrm{lbeta}(\mathbf{x}) &= \ln(|\Beta(\mathbf{x})|) \ \Beta(\mathbf{x}) = \frac{\prod_{i} \Gamma(x_i)}{\Gamma(\sum_{i} x_i)} \end{aligned}

const x = tf.tensor2d([[1, 1], [2, 2], [3, 3], [4, 4]]);

tfspecial.lbeta(x).print();

Parameters

tfspecial.betainc (a, b, x)

Compute the regularized incomplete beta integral. Defined as: betainc(a,b,x)=Ix(a,b)=B(x;a,b)B(a,b)B(x;a,b)=0xta1(1t)b1dt \begin{aligned} \mathrm{betainc}(a, b, x) &= I_x(a, b) = \frac{\Beta(x; a, b)}{\Beta(a, b)} \ \Beta(x; a, b) &= \int_{0}^{x} t^{a-1} (1-t)^{b-1},dt \end{aligned}

const a = 1;
const b = 2;
const x = tf.tensor1d([0, 0.25, 0.5, 0.75, 1]);

tfspecial.betainc(a, b, x).print();

Parameters

tfspecial.erf (x)

Computes the Gauss error function of x element-wise. Defined as: erf(x)=2π0xet2dt \mathrm{erf}(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^{2}},dt

const x = tf.tensor1d([-1, 0, 1]);

tfspecial.erf(x).print();

Parameters

tfspecial.erfc (x)

Computes the Complementary Gauss error function of x element-wise. Defined as: erfc(x)=2πxet2dt \mathrm{erfc}(x) = \frac{2}{\sqrt{\pi}} \int_{x}^{\infty} e^{-t^{2}},dt

const x = tf.tensor1d([-1, 0, 1]);

tfspecial.erfc(x).print();

Parameters

tfspecial.lgamma (x)

Computes the log of the Γ(x)\Gamma(x) element-wise. Defined as: lgamma(x)=ln(Γ(x))Γ(x)=0xz1exdx \begin{aligned} \mathrm{lgamma}(x) &= \ln(|\Gamma(x)|) \ \Gamma(x) &= \int_{0}^{\infty} x^{z-1} e^{-x},dx \end{aligned}

const x = tf.tensor1d([1, 2, 3, 4]);

tfspecial.lgamma(x).print();

Parameters

tfspecial.digamma (x)

First order derivative of ln(Γ(x))\ln(|\Gamma(x)|) element-wise. Defined as: digamma(x)=ψ(x)=ddxln(Γ(x)) \mathrm{digamma}(x) = \psi(x) = \frac{d}{dx}\ln(|\Gamma(x)|)

const x = tf.tensor1d([1, 2, 3, 4]);

tfspecial.digamma(x).print();

Parameters

tfspecial.polygamma (m, x)

m + 1 order derivative of ln(Γ(x))\ln(|\Gamma(x)|) element-wise. Defined as: polygamma(m,x)=ψ(m)(x)=dm+1dxm+1ln(Γ(x)) \mathrm{polygamma}(m, x) = \psi^{(m)}(x) = \frac{d^{m+1}}{dx^{m+1}}\ln(|\Gamma(x)|)

const m = tf.tensor2d([0, 1, 2, 3], [1, 4]);
const x = tf.tensor2d([1, 2, 3, 4], [4, 1]);

tfspecial.polygamma(m, x).print();

Parameters

tfspecial.igamma (a, x)

The lower regularized incomplete Gamma function. Defined as: igamma(a,x)=γ(a,x)Γ(a)γ(a,x)=0xts1etdt \begin{aligned} \mathrm{igamma}(a, x) &= \frac{\gamma(a, x)}{\Gamma(a)} \ \gamma(a, x) &= \int_{0}^{x} t^{s-1} e^{-t},dt \end{aligned}

const a = tf.tensor2d([1, 2, 3, 4], [4, 1]);
const x = tf.tensor2d([1, 2, 5, 10], [1, 4]);

tfspecial.igamma(a, x).print();

Parameters

tfspecial.igammac (a, x)

The upper regularized incomplete Gamma function. Defined as: igammac(a,x)=Γ(a,x)Γ(a)Γ(a,x)=xts1etdt \begin{aligned} \mathrm{igammac}(a, x) &= \frac{\Gamma(a, x)}{\Gamma(a)} \ \Gamma(a, x) &= \int_{x}^{\infty} t^{s-1} e^{-t},dt \end{aligned}

const a = tf.tensor2d([1, 2, 3, 4], [4, 1]);
const x = tf.tensor2d([1, 2, 5, 10], [1, 4]);

tfspecial.igammac(x).print();

Parameters

tfspecial.zeta (x, q)

Compute the Hurwitz zeta function element-wise. Defined as: zeta(x)=Z(x,q)=01(q+n)x \mathrm{zeta}(x) = \Zeta(x, q) = \sum_{0}^{\infty} \frac{1}{(q + n)^x}

const x = tf.tensor2d([2, 3, 4, 5], [4, 1]);
const q = tf.tensor2d([1, 2, 3, 4], [1, 4]);

tfspecial.zeta(x, q).print();

Parameters

TF.js Special