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

[ENH] Logistic distribution #241

Merged
merged 10 commits into from
Apr 18, 2024
Merged

[ENH] Logistic distribution #241

merged 10 commits into from
Apr 18, 2024

Conversation

malikrafsan
Copy link
Contributor

@malikrafsan malikrafsan commented Apr 6, 2024

Reference Issues/PRs

#22

What does this implement/fix? Explain your changes.

Logistic probability distribution

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

no

What should a reviewer concentrate their feedback on?

  • Energy formula for logistic distribution

Did you add any tests for the change?

  • Yes, I try to install this library locally using pip install --editable .[dev,test] and create simple driver program to use this new distribution

Any other comments?

  • I use the formula from Wikipedia, which can be accessed here
  • For log_pdf, I use wolfram alpha to derive the formula, here is the screenshot
    Screenshot from 2024-04-07 01-05-52

PR checklist

For all contributions
  • I've added myself to the list of contributors with any new badges I've earned :-)
    How to: add yourself to the all-contributors file in the skpro root directory (not the CONTRIBUTORS.md). Common badges: code - fixing a bug, or adding code logic. doc - writing or improving documentation or docstrings. bug - reporting or diagnosing a bug (get this plus code if you also fixed the bug in the PR).maintenance - CI, test framework, release.
    See here for full badge reference
  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
For new estimators
  • I've added the estimator to the API reference - in docs/source/api_reference/taskname.rst, follow the pattern.
  • I've added one or more illustrative usage examples to the docstring, in a pydocstyle compliant Examples section.
  • If the estimator relies on a soft dependency, I've set the python_dependencies tag and ensured
    dependency isolation, see the estimator dependencies guide.

@fkiraly
Copy link
Collaborator

fkiraly commented Apr 6, 2024

For log_pdf, I use wolfram alpha to derive the formula

Interesting - I would just have used the standard logarithm rules to cancel exps etc.

Do you have an opinion on which representation is more stable, numerically?

Intuitively, at least, I would think cancelling as many exps as possible is better.

@fkiraly
Copy link
Collaborator

fkiraly commented Apr 6, 2024

PS: no need to close PR and reopen, if you update your branch on your fork, the PR automatically gets updated.

@malikrafsan malikrafsan marked this pull request as ready for review April 7, 2024 05:59
@malikrafsan
Copy link
Contributor Author

PS: no need to close PR and reopen, if you update your branch on your fork, the PR automatically gets updated.

Previously, I incorrectly named the branch, it should be logistic, but I named the branch as weibull, sorry about that 😅😅

@malikrafsan
Copy link
Contributor Author

Interesting - I would just have used the standard logarithm rules to cancel exps etc.

Thank you so much on your thoughts about this! Based on my manual calculation it should be

$(-\frac{x-\mu}{s}) - ln(s) - 2ln(1+e^{-\frac{x-\mu}{s}})$

Do you have an opinion on which representation is more stable, numerically?

I'm uncertain myself about which representation is numerically more stable 😅😅

Previously I leaned towards the result from Wolfram Alpha as it offered a relatively simpler equation, but I am also not really sure whether it is the best solution

After some careful consideration, I think using the standard logarithm rule would be more intuitive to use and to be read. I will change it accordingly 😅😅

@fkiraly
Copy link
Collaborator

fkiraly commented Apr 7, 2024

Thank you so much on your thoughts about this! Based on my manual calculation it should be

Looks correct to me. I'd use numpy logaddexp (or the scipy distribution directly)

@fkiraly fkiraly added enhancement module:probability&simulation probability distributions and simulators labels Apr 7, 2024
Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Thanks!

  • could you kindly add the distribution to the api reference in docs?
  • not blocking, but could you kindly look at the comment re logs and cancellation?

@malikrafsan
Copy link
Contributor Author

malikrafsan commented Apr 9, 2024

I'd use numpy logaddexp

Sure, I have adjusted the code to use the function

could you kindly add the distribution to the api reference in docs?

Sure, I have added the new class to the API reference

not blocking, but could you kindly look at the comment re logs and cancellation?

I am not sure I understand this, what does comment re logs and cancellation mean? Thank you!

Please let me know if there is any concern or feedback, thank you so much!

@fkiraly
Copy link
Collaborator

fkiraly commented Apr 10, 2024

Interesting - I would just have used the standard logarithm rules to cancel exps etc.

The above is what I meant, yes

Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

I'm assuming you're no longer working on this, so I'm wrapping this up now.

@fkiraly fkiraly merged commit f205e17 into sktime:main Apr 18, 2024
36 checks passed
@malikrafsan
Copy link
Contributor Author

I'm assuming you're no longer working on this, so I'm wrapping this up now.

Hi @fkiraly, I very much apologize for the delay in completing the PR without notifying you further. Thank you so much for wrapping this PR up. Please kindly let me know if there's anything I can assist with or if there are any adjustments needed 🙏🙏

@fkiraly
Copy link
Collaborator

fkiraly commented Apr 29, 2024

no worries - a message would have been helpful, but it is not unusual that PRs do not get completed, and we wrap those up that are close to the finish line.

Thanks for your contibutions with the scipy adapter, these are really nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement module:probability&simulation probability distributions and simulators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants