pytorch - ✅(Solved) Fix Add Frechet/Inverse Weibull distribution [1 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#179430Fetched 2026-04-08 02:51:44
View on GitHub
Comments
2
Participants
2
Timeline
20
Reactions
0
Author
Participants
Timeline (top)
labeled ×5mentioned ×4referenced ×4subscribed ×4

Root Cause

I would like the Frechet distribution (aka. Inverse Weibull distribution) to be added to torch.distributions. I am working on some simulations for insurance where such heavy-tailed distributions are common and having the function built directly into PyTorch would be helpful, because e.g. other implementations (such as scipy) require passing e.g. a numpy array and do not accept torch tensors.

PR fix notes

PR #179471: [Distributions] Add Frechet (Inverse Weibull) distribution

Description (problem / solution / changelog)

Motive

Addresses #179430. The Frechet distribution is widely used in extreme value theory and insurance simulations, and was previously missing from torch.distributions.

Solution

  • Implemented Frechet as a TransformedDistribution using a Weibull base distribution and a reciprocal transformation (PowerTransform(-1)).
  • Added analytical overrides for mean, variance, mode, and entropy to ensure numerical stability and precision.
  • Implemented expand for batch support.

Test Plan

  • Added Frechet to _get_examples and _get_bad_examples in test/distributions/test_distributions.py.
  • Verified mathematical correctness against scipy.stats.invweibull in TestAgainstScipy.
  • Verified repr, expand, jit, and grad checks via the generic distribution test suite.

Fixes #179430

cc @fritzo @neerajprad @alicanb @nikitaved

Changed files

  • test/distributions/test_distributions.py (modified, +40/-0)
  • torch/distributions/__init__.py (modified, +2/-0)
  • torch/distributions/frechet.py (added, +107/-0)
RAW_BUFFERClick to expand / collapse

🚀 The feature, motivation and pitch

Proposal

I would like the Frechet distribution (aka. Inverse Weibull distribution) to be added to torch.distributions. I am working on some simulations for insurance where such heavy-tailed distributions are common and having the function built directly into PyTorch would be helpful, because e.g. other implementations (such as scipy) require passing e.g. a numpy array and do not accept torch tensors.

Alternatives

I hope this idea is compatible with the long term goals of PyTorch. If it is not, could you please point me to a different PyTorch-compatible library, where this exists or could be implemented?

Additional context

For implementation, the Frechet distribution could be expressed as a transformation of the Weibull distribution with an affine transformation for location parameter: https://en.wikipedia.org/wiki/Fr%C3%A9chet_distribution#Related_distributions.

cc @fritzo @neerajprad @alicanb @nikitaved

extent analysis

TL;DR

Implementing the Frechet distribution in torch.distributions or finding a PyTorch-compatible library that supports it could resolve the issue.

Guidance

  • Review the PyTorch documentation and existing libraries to determine if the Frechet distribution is already available or if there are plans to add it.
  • Consider implementing the Frechet distribution as a transformation of the Weibull distribution, using the affine transformation for the location parameter as described in the Wikipedia article.
  • Look into existing PyTorch-compatible libraries that may already support the Frechet distribution, such as those mentioned in the alternatives section.
  • If implementation is necessary, start by creating a prototype using PyTorch tensors to ensure compatibility.

Example

No code example is provided due to the lack of specific implementation details in the issue.

Notes

The solution may depend on the specific requirements of the project, such as performance or accuracy constraints. Additionally, the implementation details may vary depending on the chosen approach.

Recommendation

Apply workaround: Implement the Frechet distribution using a transformation of the Weibull distribution or find a PyTorch-compatible library that supports it, as this approach allows for a flexible and compatible solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - ✅(Solved) Fix Add Frechet/Inverse Weibull distribution [1 pull requests, 2 comments, 2 participants]