Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC]: skew-normal distribution #492

Open
3 tasks done
quinn-dougherty opened this issue May 7, 2022 · 8 comments · May be fixed by #2110
Open
3 tasks done

[RFC]: skew-normal distribution #492

quinn-dougherty opened this issue May 7, 2022 · 8 comments · May be fixed by #2110
Labels
Feature Issue or pull request for adding a new feature. RFC Request for comments. Feature requests and proposed changes. Statistics Issue or pull request related to statistical functionality.

Comments

@quinn-dougherty
Copy link

Description

This RFC proposes the skew-normal distribution

Related Issues

I didn't see any.

Questions

No.

Other

No.

Checklist

  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.
@quinn-dougherty quinn-dougherty added Feature Issue or pull request for adding a new feature. RFC Request for comments. Feature requests and proposed changes. labels May 7, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 7, 2022

🎉 Welcome! 🎉

And thank you for opening your first issue! We will get back to you shortly. 🏃 💨

@kgryte
Copy link
Member

kgryte commented May 7, 2022

Hey, @quinn-dougherty! Thanks for filing this RFC.

This would definitely be a nice distribution to have. Does entail, however, a more involved implementation. Namely, we'd need integration facilities (see SciPy) and Owen's T function (see https://www.jstatsoft.org/article/view/v005i05 (GPL)).

@Planeshifter May have a better sense of how difficult this distribution may be to implement.

@kgryte kgryte added the Statistics Issue or pull request related to statistical functionality. label May 7, 2022
@jqhoogland
Copy link

jqhoogland commented Sep 3, 2022

For now, this is getting the job done for me:

skew_normal(params) = {
    loc = params.loc
    scale = params.scale
    shape = params.shape

    {|x| (2 / scale) * pdf(normal(loc, scale), x) * cdf(normal(loc, scale), shape * x)}
}

(when a function suffices)

Or this incredibly janky thing:


skew_normal(params) = {
    _skew_normal(params) = {
        loc = params.loc
        scale = params.scale
        shape = params.shape

        {|x| (2 / scale) * pdf(normal(loc, scale), x) * cdf(normal(loc, scale), shape * x)}
    }

    range = List.upTo((params.loc - params.scale * 3) * 100, (params.loc + params.scale * 3) * 100)
    PointSet.makeContinuous(range |> map({|x| {x: x/ 100, y: _skew_normal(params)(x/100)}}))
}

(when I need a proper distribution)

@Prog-Jacob
Copy link

Prog-Jacob commented Mar 29, 2024

Hey, @kgryte!

I would like to work on that. I checked the SciPy source code you shared; they are using direct implementation of the formula here. On the contrary, in the paper, they are utilizing Owen's T function properties to bring down the $\text{shape } (a)$ to $0 \le a \le1$. Then, they use one of six approximation methods depending on the value of h and a. One of these methods is the Gaussian quadrature, which I think is sufficient for now and wouldn't require integration facilities. Also, Owen's T function will be needed in the Multivariate Normal Distributions (GSoC listed ideas), and this can be a good starter for whom will work on it.

@kgryte
Copy link
Member

kgryte commented Mar 29, 2024

@Prog-Jacob As a start, feel free to submit an initial PR which adds the pdf to @stdlib/stats/base/dists/skew-normal/pdf.

@kgryte
Copy link
Member

kgryte commented Mar 29, 2024

@Prog-Jacob Or perhaps take an initial pass at adding Owen's T to @stdlib/math/base/special/owens-t, based on Boost: https://github.com/boostorg/math/blob/15c40fae1610fd83728d75e96d7377fe55f976f7/include/boost/math/special_functions/owens_t.hpp#L1030

@Prog-Jacob
Copy link

Prog-Jacob commented Mar 30, 2024

@kgryte Boost is implementing the paper you referenced – Fast and Accurate Calculation of Owen's T Function. It looks hefty; should I initially focus on supporting Skewed Normal Distributions and work on Owen's T function later on? what do you think?

@kgryte
Copy link
Member

kgryte commented Mar 30, 2024

@Prog-Jacob Sure. Sounds good.

@Prog-Jacob Prog-Jacob linked a pull request Apr 2, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Issue or pull request for adding a new feature. RFC Request for comments. Feature requests and proposed changes. Statistics Issue or pull request related to statistical functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants