diff --git a/content/pytorch/concepts/tensor-operations/terms/i0/i0.md b/content/pytorch/concepts/tensor-operations/terms/i0/i0.md new file mode 100644 index 00000000000..c07a4521ca5 --- /dev/null +++ b/content/pytorch/concepts/tensor-operations/terms/i0/i0.md @@ -0,0 +1,64 @@ +--- +Title: '.i0()' +Description: 'Computes the modified Bessel function of the first kind of order zero.' +Subjects: + - 'AI' + - 'Data Science' + - 'Machine Learning' +Tags: + - 'AI' + - 'Deep Learning' + - 'Functions' + - 'Machine Learning' + - 'PyTorch' +CatalogContent: + - 'intro-to-py-torch-and-neural-networks' + - 'paths/computer-science' +--- + +In PyTorch, the **`.i0()`** function (an alias of `torch.special.i0()`) computes the modified Bessel function of the first kind of order zero (I₀). This function is commonly used in signal processing, physics simulations, and statistical distributions such as the von Mises distribution for circular data. + +## Syntax + +```pseudo +torch.i0(input, *, out=None) +``` + +Or, alternatively: + +```pseudo +torch.special.i0(input, *, out=None) +``` + +**Parameters:** + +- `input` (Tensor): The input tensor whose elements are the values at which to compute the modified Bessel function I₀. +- `out` (Tensor, optional): The output tensor to store the result. + +**Return value:** + +Returns a tensor containing the computed modified Bessel function of the first kind, order zero (I₀), for each element of the input tensor. + +## Example + +In this example, `torch.i0()` calculates the modified Bessel function I₀ for each element in a 1D tensor: + +```py +import torch + +# Create input tensor +x = torch.tensor([0.0, 1.0, 2.0, 3.0, 4.0]) + +# Compute the modified Bessel function +result = torch.i0(x) + +print("Input values:", x) +print("I₀(x) values:", result) +``` + +The above code produces the following output: + +```shell +Input values: tensor([0., 1., 2., 3., 4.]) +I₀(x) values: tensor([1.0000, 1.2661, 2.2796, 4.8808, 11.3019]) +```