Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 26, 2025

Implements the Pareto Type II distribution corresponding to GAMLSS PARETO2() family.

Implementation

  • Distribution class: Pareto using ScipyMixin with scipy.stats.lomax
  • Parameterization: GAMLSS (μ, σ) → scipy (scale=μ, c=σ, loc=0)
  • Derivatives: Observed information (depends on y)
    • First: dl/dμ = (σy - μ)/(μ(μ+y)), dl/dσ = 1/σ - log(1 + y/μ)
    • Second: d²l/dμ² = (μ² - 2μσy - σy²)/(μ²(μ+y)²), d²l/dσ² = -1/σ²
    • Cross: d²l/dμdσ = y/(μ(μ+y))

Files

  • src/ondil/distributions/pareto.py - Main implementation
  • src/ondil/distributions/__init__.py - Export added

Usage

from ondil.distributions import Pareto
from ondil.estimators import OnlineDistributionalRegression

estimator = OnlineDistributionalRegression(
    distribution=Pareto(),
    equation={0: np.array([0, 1]), 1: np.array([0, 1])},
    method="ols"
)
estimator.fit(X=X, y=y)

PDF: f(y|μ,σ) = σ/(μ(1 + y/μ)^(σ+1)) for y ≥ 0, μ > 0, σ > 0

Original prompt

This section details on the original issue you should resolve

<issue_title>Add distribution: Pareto</issue_title>
<issue_description>https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.lomax.html#scipy.stats.lomax</issue_description>

<agent_instructions>Please develop the distribution.

  • Use the scipyMixin class to re-use scipy infrastructure.
  • Use the generalized tests in tests/distribution/test_xxx.py to test the CDF, PPF, .... and the derivatives.
  • Use the skew-t and the normal distributions as example. Use case match in favour of older if -else code. Use the gama distribution as example for mapping scipy and gamlss parameterizations if they differ.

https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.lomax.html#scipy.stats.pareto

https://github.com/gamlss-dev/gamlss.dist/blob/main/R/PARETO2.R</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits October 26, 2025 09:49
Co-authored-by: simon-hirsch <64348015+simon-hirsch@users.noreply.github.com>
Co-authored-by: simon-hirsch <64348015+simon-hirsch@users.noreply.github.com>
Copilot AI changed the title [WIP] Add distribution implementation for Pareto Add Pareto Type II (Lomax) distribution Oct 26, 2025
Copilot AI requested a review from simon-hirsch October 26, 2025 09:58
Copy link
Owner

@simon-hirsch simon-hirsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot the derivatives seem not to match. Please look at the output of the automated tests.

@copilot please dont implement a test for the coefficients manually.

Co-authored-by: simon-hirsch <64348015+simon-hirsch@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 26, 2025

@copilot the derivatives seem not to match. Please look at the output of the automated tests.

@copilot please dont implement a test for the coefficients manually.

Fixed the derivatives to use observed information instead of expected Fisher information, matching GAMLSS PARETO2(). Also removed the manual coefficient test files as requested. Changes in commit b075bbf.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add distribution: Pareto

2 participants