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

Fixed Wrong Integral from SingleContinuousPSpace #18336

Merged
merged 9 commits into from
Jan 20, 2020

Conversation

Smit-create
Copy link
Member

Fixes Wrong Integral from SingleContinuousPSpace.

References to other Issues or PRs

Fixes #10076

Brief description of what is fixed or changed

Before:

>>> from sympy import Symbol
>>> from sympy.stats.crv_types import NormalDistribution
>>> from sympy.stats.crv import SingleContinuousPSpace
>>> x = Symbol('x')
>>> a = SingleContinuousPSpace(x, NormalDistribution(2, 4))
>>> a.probability(x < 1)
Integral(0, (_z, -oo, 0))

After:

>>> from sympy import Symbol
>>> from sympy.stats.crv_types import NormalDistribution
>>> from sympy.stats.crv import SingleContinuousPSpace
>>> x = Symbol('x')
>>> a = SingleContinuousPSpace(x, NormalDistribution(2, 4))
>>> a.probability(x < 1)
Integral(sqrt(2)*exp(-(_z - 2)**2/32)/(8*sqrt(pi)), (_z, -oo, 1))

Other comments

Release Notes

  • stats
    • Fixes Wrong Integral result from SingleContinuousPSpace

@sympy-bot
Copy link

sympy-bot commented Jan 14, 2020

Hi, I am the SymPy bot (v149). 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.6.

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. -->
Fixes Wrong Integral from SingleContinuousPSpace.
#### 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://github.com/blog/1506-closing-issues-via-pull-requests . Please also
write a comment on that issue linking back to this pull request once it is
open. -->
Fixes #10076

#### Brief description of what is fixed or changed
Before:
```
>>> from sympy import Symbol
>>> from sympy.stats.crv_types import NormalDistribution
>>> from sympy.stats.crv import SingleContinuousPSpace
>>> x = Symbol('x')
>>> a = SingleContinuousPSpace(x, NormalDistribution(2, 4))
>>> a.probability(x < 1)
Integral(0, (_z, -oo, 0))

```
After:
```
>>> from sympy import Symbol
>>> from sympy.stats.crv_types import NormalDistribution
>>> from sympy.stats.crv import SingleContinuousPSpace
>>> x = Symbol('x')
>>> a = SingleContinuousPSpace(x, NormalDistribution(2, 4))
>>> a.probability(x < 1)
Integral(sqrt(2)*exp(-(_z - 2)**2/32)/(8*sqrt(pi)), (_z, -oo, 1))
```
#### 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
  * Fixes Wrong Integral result from SingleContinuousPSpace
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@Smit-create
Copy link
Member Author

Smit-create commented Jan 15, 2020

@oscarbenjamin @czgdp1807 Does it seems good now?it is also applicable to all the continuous distributions.

@Smit-create
Copy link
Member Author

@czgdp1807 @oscarbenjamin Is it ready to merge?

@oscarbenjamin
Copy link
Contributor

I left a couple of minor comments. This looks fine to me but I don't know the stats part of the codebase very well.

@Smit-create
Copy link
Member Author

@czgdp1807 Updated with suggested changes, Is this now ready to merge?

sympy/stats/crv.py Outdated Show resolved Hide resolved
@czgdp1807
Copy link
Member

LGTM. Will merge if no one objects for some time. Until then you can merge master and push here(for double surety).

@codecov
Copy link

codecov bot commented Jan 19, 2020

Codecov Report

Merging #18336 into master will increase coverage by 0.261%.
The diff coverage is 81.701%.

@@              Coverage Diff              @@
##            master    #18336       +/-   ##
=============================================
+ Coverage   75.031%   75.293%   +0.261%     
=============================================
  Files          649       633       -16     
  Lines       167370    166922      -448     
  Branches     39421     39391       -30     
=============================================
+ Hits        125581    125682      +101     
+ Misses       36249     35705      -544     
+ Partials      5540      5535        -5

@czgdp1807 czgdp1807 merged commit 944b688 into sympy:master Jan 20, 2020
@Smit-create Smit-create deleted the 10076 branch January 20, 2020 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SingleContinuousPSpace(x, NormalDistribution(2, 4)).probability(x < 1) return Wrong Integral
4 participants