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
Conversation
✅ 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.
Update The release notes on the wiki have been updated. |
@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) ⋅ℯ
⎮ ─────────────────────── dX
⎮ 4⋅√π
⌡
-∞
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) ⋅ℯ
⎮ ─────────────────────── dX
⎮ 4⋅√π
⌡
-∞
In [14]: M.rewrite(Expectation).expand()
Out[14]: 9 - 6⋅Expectation(X) + Expectation(X**2)
In [15]: M.rewrite(Expectation).expand().doit()
Out[15]: 8 |
Codecov Report
@@ 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 |
@Upabjojr @czgdp1807 Please have a look if this looks good to merge. |
Looks okay. |
It looks ok to me as well. |
References to other Issues or PRs
Fixes #6323
Related comment #6323 (comment)
Brief description of what is fixed or changed
Other comments
Release Notes
Moment
andCentralMoment
ping @Upabjojr @czgdp1807 @jmig5776