Skip to content

feat: Add Azzalini Skew-Normal Distribution - #2028

Open
nareshmethuku wants to merge 1 commit into
tensorflow:mainfrom
nareshmethuku:add-skew-normal
Open

feat: Add Azzalini Skew-Normal Distribution#2028
nareshmethuku wants to merge 1 commit into
tensorflow:mainfrom
nareshmethuku:add-skew-normal

Conversation

@nareshmethuku

Copy link
Copy Markdown

This PR introduces the Azzalini SkewNormal distribution to tfp.distributions, providing a continuous probability distribution that generalizes the normal distribution to allow for non-zero skewness.

This distribution is critical for robust statistical modeling where data exhibits asymmetry, such as in finance, survival analysis, and signal processing.

Implementation Details:

  • Distribution Architecture: The distribution natively inherits from AutoCompositeTensorDistribution and implements standard TFP broadcasting patterns.
  • Analytic CDF Integration: The cumulative distribution function relies on Owen's T function. Rather than re-implementing an approximation, this PR seamlessly binds to TFP's highly-optimized internal math.special.owens_t, providing numeric stability and tight compliance with SciPy baselines.
  • Analytic Reparameterization: SkewNormal implements FULLY_REPARAMETERIZED sampling. To avoid the inefficiencies of rejection sampling, the sampler employs the precise $\delta$-reparameterization technique ($Z = \delta |U_0| + \sqrt{1 - \delta^2} V$, where $U_0, V \sim \mathcal{N}(0, 1)$), producing robust automatic gradients natively under tf.GradientTape.
  • Numerical Stability: Utilized math.special.log_ndtr and math.special.log1psquare internally to ensure numerically stable computations for extreme inputs.

Testing & Verification

  • Added rigorous test coverage in skew_normal_test.py.
  • Verified numeric equivalence of the PDF, CDF, log-prob, mean, and variance against scipy.stats.skewnorm.
  • Validated sampling statistics against analytical mean/variance equations for 100,000 samples to tight relative tolerances.
  • Tests automatically run over all execution regimes (Eager, Graph, and tf.function) utilizing @test_util.test_all_tf_execution_regimes.
  • Tested reparameterization tape gradients.

Checklist:

  • Added skew_normal.py and skew_normal_test.py
  • Exported SkewNormal via __init__.py
  • Registered bazel build targets in BUILD
  • Verified all tests pass successfully

@google-cla

google-cla Bot commented Jul 29, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant