Skip to content

beta_wavelet

Bases: discrete_wavelet

Beta wavelet implementation.

This wavelet uses the beta distribution for its wavelet function.

Source code in tinybig/koala/signal_processing/wavelet.py
class beta_wavelet(discrete_wavelet):
    """
    Beta wavelet implementation.

    This wavelet uses the beta distribution for its wavelet function.
    """
    def __init__(self, alpha: float = 1.0, beta: float = 1.0, name: str = 'beta_wavelet', *args, **kwargs):
        """
        Initialize the Beta wavelet.

        Parameters
        ----------
        alpha : float, optional
            Alpha parameter of the beta distribution. Must be >= 1. Default is 1.0.
        beta : float, optional
            Beta parameter of the beta distribution. Must be >= 1. Default is 1.0.
        name : str, optional
            Name of the wavelet. Default is 'beta_wavelet'.
        *args, **kwargs
            Additional parameters.
        """
        super().__init__(name=name, *args, **kwargs)
        self.alpha = alpha
        self.beta = beta
        if self.alpha < 1.0 or self.beta < 1.0:
            raise ValueError('alpha and beta must be >= 1.')

    def psi(self, tau: torch.Tensor):
        """
        Define the Beta wavelet function.

        Parameters
        ----------
        tau : torch.Tensor
            Transformed input values.

        Returns
        -------
        torch.Tensor
            Wavelet values for the input.
        """
        if not torch.all((tau >= 0) & (tau <= 1)):
            tau = torch.sigmoid(tau)
        assert torch.all((tau >= 0) & (tau <= 1))
        beta_coeff = 1.0/beta(self.alpha, self.beta)
        return beta_coeff * tau**(self.alpha - 1) * (1.0 - tau)**(self.beta - 1.0)

__init__(alpha=1.0, beta=1.0, name='beta_wavelet', *args, **kwargs)

Initialize the Beta wavelet.

Parameters:

Name Type Description Default
alpha float

Alpha parameter of the beta distribution. Must be >= 1. Default is 1.0.

1.0
beta float

Beta parameter of the beta distribution. Must be >= 1. Default is 1.0.

1.0
name str

Name of the wavelet. Default is 'beta_wavelet'.

'beta_wavelet'
*args

Additional parameters.

()
**kwargs

Additional parameters.

()
Source code in tinybig/koala/signal_processing/wavelet.py
def __init__(self, alpha: float = 1.0, beta: float = 1.0, name: str = 'beta_wavelet', *args, **kwargs):
    """
    Initialize the Beta wavelet.

    Parameters
    ----------
    alpha : float, optional
        Alpha parameter of the beta distribution. Must be >= 1. Default is 1.0.
    beta : float, optional
        Beta parameter of the beta distribution. Must be >= 1. Default is 1.0.
    name : str, optional
        Name of the wavelet. Default is 'beta_wavelet'.
    *args, **kwargs
        Additional parameters.
    """
    super().__init__(name=name, *args, **kwargs)
    self.alpha = alpha
    self.beta = beta
    if self.alpha < 1.0 or self.beta < 1.0:
        raise ValueError('alpha and beta must be >= 1.')

psi(tau)

Define the Beta wavelet function.

Parameters:

Name Type Description Default
tau Tensor

Transformed input values.

required

Returns:

Type Description
Tensor

Wavelet values for the input.

Source code in tinybig/koala/signal_processing/wavelet.py
def psi(self, tau: torch.Tensor):
    """
    Define the Beta wavelet function.

    Parameters
    ----------
    tau : torch.Tensor
        Transformed input values.

    Returns
    -------
    torch.Tensor
        Wavelet values for the input.
    """
    if not torch.all((tau >= 0) & (tau <= 1)):
        tau = torch.sigmoid(tau)
    assert torch.all((tau >= 0) & (tau <= 1))
    beta_coeff = 1.0/beta(self.alpha, self.beta)
    return beta_coeff * tau**(self.alpha - 1) * (1.0 - tau)**(self.beta - 1.0)