Skip to content

thetazero

This module contains functions to calculate the angle $\theta_0$ with a normal distribution.

isotropic.thetazero

This module contains functions for generating $\theta_0$.

get_theta_zero(x, g)

Calculate the inverse angle $\theta_0$ with a normal distribution given a value x.

This function finds the angle $\theta_0$ such that the integral of g from 0 to $\theta_0$ equals x. It uses Simpson's rule for numerical integration and a bisection method to find the root.

Parameters:

Name Type Description Default
x ArrayLike

Value for which to find the inverse, should be uniformly distributed in $[0, 1]$.

required
g Callable

Function $g(\theta)$ that is integrated to calculate $F(\theta)$.

required

Returns:

Type Description
float

Value of $\theta_0$.

Source code in src/isotropic/thetazero.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def get_theta_zero(x: ArrayLike, g: Callable) -> float:
    """
    Calculate the inverse angle $\\theta_0$ with a normal distribution given a value x.

    This function finds the angle $\\theta_0$ such that the integral of g from 0 to $\\theta_0$ equals x.
    It uses Simpson's rule for numerical integration and a bisection method to find the root.

    Parameters
    ----------
    x : ArrayLike
        Value for which to find the inverse, should be uniformly distributed in $[0, 1]$.
    g : Callable
        Function $g(\\theta)$ that is integrated to calculate $F(\\theta)$.

    Returns
    -------
    float
        Value of $\\theta_0$.
    """

    # We wrap the function g into a callable F that integrates g from 0 to theta.
    def F(theta: float) -> Array:
        # TODO: Provide the correct value for C based on the 4th derivative bound
        return simpsons_rule(g, 0, theta, 1, 1e-9)

    # Use bisection to find theta_0 such that the integral equals x
    theta_zero: float = get_theta(F, 0, jnp.pi, x, 1e-9)

    return theta_zero