Skip to content

[DOC] Add formula docs for Uniform distribution - #1123

Open
Vidit-lab wants to merge 1 commit into
sktime:mainfrom
Vidit-lab:docs/uniform-formula-docs
Open

[DOC] Add formula docs for Uniform distribution#1123
Vidit-lab wants to merge 1 commit into
sktime:mainfrom
Vidit-lab:docs/uniform-formula-docs

Conversation

@Vidit-lab

Copy link
Copy Markdown

Reference Issues/PRs

Part of #1120

What does this implement/fix? Explain your changes.

Populates the _formula_docs dictionary for Uniform (skpro/distributions/uniform.py) covering all seven exact methods (pdf, log_pdf, cdf, ppf, mean, var, energy).

Refactors standalone formula attributes (_pdf_formula_doc, _log_pdf_formula_doc, and _cdf_formula_doc) into the single _formula_docs structure.

Mathematical References & Derivations

Since the closed-form math for _pdf, _log_pdf, _cdf, _ppf, _mean, _var, _energy_self, and _energy_x is already implemented in uniform.py, the formulas in _formula_docs document these existing operations:

  1. Standard Properties (pdf, log_pdf, cdf, ppf, mean, var):

    • Reference: Bertsekas, D. P., & Tsitsiklis, J. N. (2008). Introduction to Probability (2nd ed.). Athena Scientific, Chapter 3 (Continuous Random Variables).
  2. Self-Energy ($\mathbb{E}[|X - Y|]$):

    For $X, Y \stackrel{\text{i.i.d.}}{\sim} U(a,b)$ with joint density $f(x, y) = \frac{1}{(b - a)^2}$:

    $$\mathbb{E}[|X - Y|] = \frac{1}{(b - a)^2} \int_{a}^{b} \int_{a}^{b} |x - y| , dx , dy$$

    Exploiting symmetry across $x = y$:

    $$\mathbb{E}[|X - Y|] = \frac{2}{(b - a)^2} \int_{a}^{b} \left( \int_{a}^{x} (x - y) , dy \right) dx = \frac{2}{(b - a)^2} \int_{a}^{b} \frac{(x - a)^2}{2} , dx = \frac{b - a}{3}$$

    Matches _energy_self return value (upper - lower) / 3.

  3. Point Energy ($\mathbb{E}[|X - x|]$):

    Evaluated for constant $x$:

    $$\mathbb{E}[|X - x|] = \int_{a}^{b} |t - x| \frac{1}{b - a} , dt$$

    For $x \in [a, b]$, splitting the integral at $t = x$ yields:

    $$\mathbb{E}[|X - x|] = \frac{(b - x)^2 + (a - x)^2}{2(b - a)}$$

    For $x < a$ or $x > b$, direct evaluation yields $\left| x - \frac{a + b}{2} \right|$.

    Matches _energy_x logic.

Does your contribution introduce a new dependency? If yes, which one?

No.

What should a reviewer concentrate their feedback on?

  • LaTeX rendering formatting inside _formula_docs.

Did you add any tests for the change?

Added Uniform to HOOKED_CLASSES in test_docstring_injection.py.

Any other comments?

None.

PR checklist

  • I've added myself to the list of contributors in the skpro root directory.
  • The PR title starts with [DOC].

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