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

[GSoC] Added symbolic classes for Moment and Centralmoment #19724

Merged
merged 4 commits into from Jul 12, 2020

Conversation

Smit-create
Copy link
Member

@Smit-create Smit-create commented Jul 7, 2020

References to other Issues or PRs

Fixes #6323
Related comment #6323 (comment)

Brief description of what is fixed or changed

  • Add classes of Moment and CentralMoment and their docs
  • Tests

Other comments

Release Notes

  • stats
    • Added symbolic classes of Moment and CentralMoment

ping @Upabjojr @czgdp1807 @jmig5776

@sympy-bot
Copy link

sympy-bot commented Jul 7, 2020

Hi, I am the SymPy bot (v160). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.7.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->
Fixes #6323 
Related comment https://github.com/sympy/sympy/issues/6323#issuecomment-654743869

#### Brief description of what is fixed or changed
- [x] Add classes of Moment and CentralMoment and their docs
- [x] Tests

#### Other comments


#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* stats
   *  Added symbolic classes of `Moment` and `CentralMoment`
<!-- END RELEASE NOTES -->
ping @Upabjojr @czgdp1807 @jmig5776 

Update

The release notes on the wiki have been updated.

@Smit-create
Copy link
Member Author

Smit-create commented Jul 7, 2020

@Upabjojr @czgdp1807 I get the following results on the current diff, Please see if these are the expected results:

In [1]: from sympy.stats import *

In [2]: X = Normal('X', 1, 2)

In [3]: M = Moment(X, 2, 3)

In [4]: M
Out[4]: Moment(X, 2, 3)

In [5]: M.doit()
Out[5]: 8

In [6]: M.rewrite(Expectation)

Out[6]: Expectation((X - 3)**2)

In [7]: M.rewrite(Probability)
Out[7]:
∞
⌠
⎮         2
⎮  (x - 3) ⋅Probability(Eq(X, x)) dx-In [8]: M.rewrite(Integral)
Out[8]:
∞
⌠
⎮                       2-(X - 1)

⎮               ──────────
⎮            2      8
⎮  √2⋅(X - 3) ⋅
⎮  ─────────────────────── dX4⋅√π-In [9]: m = moment(X, 2, 3)

In [11]: m
Out[11]: 8

In [12]: m = moment(X, 2, 3, evaluate=False)

In [13]: m
Out[13]:
∞
⌠
⎮                       2-(X - 1)
⎮               ──────────
⎮            2      8
⎮  √2⋅(X - 3) ⋅
⎮  ─────────────────────── dX4⋅√π-In [14]: M.rewrite(Expectation).expand()
Out[14]: 9 - 6Expectation(X) + Expectation(X**2)

In [15]: M.rewrite(Expectation).expand().doit()
Out[15]: 8

@codecov
Copy link

codecov bot commented Jul 7, 2020

Codecov Report

Merging #19724 into master will decrease coverage by 11.315%.
The diff coverage is 91.111%.

@@              Coverage Diff               @@
##            master    #19724        +/-   ##
==============================================
- Coverage   75.707%   64.391%   -11.316%     
==============================================
  Files          659       659                
  Lines       171329    171376        +47     
  Branches     40415     40422         +7     
==============================================
- Hits        129709    110352     -19357     
- Misses       35977     54741     +18764     
- Partials      5643      6283       +640     

@Smit-create Smit-create changed the title [GSoC] Added symbolic classes for Moment and Cmoment [GSoC] Added symbolic classes for Moment and Centralmoment Jul 9, 2020
@Smit-create
Copy link
Member Author

@Upabjojr @czgdp1807 Please have a look if this looks good to merge.

@czgdp1807
Copy link
Member

Looks okay.

@Upabjojr
Copy link
Contributor

It looks ok to me as well.

@czgdp1807 czgdp1807 merged commit 47670c1 into sympy:master Jul 12, 2020
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.

Generating Functions for sympy.stats
5 participants