WIP: More distributions #1413

Merged
merged 17 commits into from Jan 19, 2013

Projects

None yet

7 participants

@raoulb
Contributor
raoulb commented Jul 12, 2012

Even more continuous distribution functions

@travisbot

This pull request fails (merged 26c4adfc into 9ff4edf).

@Krastanov
Member

SymPy Bot Summary: 🔴 There were test failures.

@raoulb: Please fix the test failures.

Test command: setup.py test
master hash: 9ff4edf
branch hash: 26c4adfccac2ec2ee5630129f8a59164e201f9e1

Interpreter 1: ✳️ All tests have passed.

Interpreter: /usr/local/bin/python2.5 (2.5.6-final-0)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY_-0fDA

Interpreter 2: 🔴 There were test failures.

Interpreter: /usr/bin/python2.7 (2.7.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYxq8fDA

Interpreter 3: 🔴 There were test failures.

Interpreter: /usr/bin/python3.2 (3.2.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYz9YfDA

Build HTML Docs: 🔴 There were test failures.

Docs build command: make html-errors
Sphinx version: 1.1.3

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYvYgfDA

Automatic review by SymPy Bot.

@certik
Member
certik commented Aug 11, 2012

It needs regular tests before we can merge it.

@raoulb
Contributor
raoulb commented Aug 14, 2012

I plan to add some more distribution in this PR.
Let's just keep it open for the moment.

@travisbot

This pull request fails (merged 8691d70b into a184841).

@travisbot

This pull request passes (merged e49899e8 into a184841).

@raoulb
Contributor
raoulb commented Aug 24, 2012

Do we want this to get into SymPy 0.7.2?
If yes, so lets merge it now.
If no, I will continue adding distributions on top of this PR some day.

@travisbot

This pull request passes (merged 7508eec6 into a184841).

@asmeurer
Member

I already created the 0.7.2 branch and would like to keep it for bug fixes and API changes only, so let's shoot for 0.7.3 for this.

Even so, if the work here is ok as is, this can be merged into master and you can open new PRs for further distributions.

@jrioux
Member
jrioux commented Aug 27, 2012

SymPy Bot Summary: ✳️ All tests have passed.

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYhYYlDA

Interpreter: /usr/bin/python (2.7.0-final-0)
Architecture: Linux (32-bit)
Cache: yes
Test command: setup.py test
master hash: 161c963
branch hash: 7508eec61039aff06ab7709c8afc14d7023baf2e

Automatic review by SymPy Bot.

@jrioux
Member
jrioux commented Aug 27, 2012

SymPy Bot Summary: ✳️ All tests have passed.

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYkOIjDA

Interpreter: /usr/bin/python (2.7.2-final-0)
Architecture: Linux (64-bit)
Cache: yes
Test command: setup.py test
master hash: 161c963
branch hash: 7508eec61039aff06ab7709c8afc14d7023baf2e

Automatic review by SymPy Bot.

@jrioux
Member
jrioux commented Sep 13, 2012

SymPy Bot Summary: ✳️ Passed after merging raoulb/more_distributions (7508eec61039aff06ab7709c8afc14d7023baf2e) into master (c49dca1).
✳️ Python 2.7.2-final-0: pass
✳️ Python 3.2.1-final-0: pass
✳️Sphinx 1.1.3: pass
Docs build command: make clean && make html-errors && make clean && make latex && cd _build/latex && xelatex -interaction=nonstopmode sympy-*.tex

@jrioux
Member
jrioux commented Sep 27, 2012

SymPy Bot Summary: ✳️ Passed after merging raoulb/more_distributions (a24f147ea86cc4984c01d969da4f1a6270d9ec11) into master (93f6ce3).
✳️ Python 2.7.2-final-0: pass
✳️ Python 3.2.1-final-0: pass
✳️Sphinx 1.1.3: pass
Docs build command: make clean && make html-errors && make clean && make latex && cd _build/latex && xelatex sympy-*.tex

@jrioux
Member
jrioux commented Oct 22, 2012

SymPy Bot Summary: ❗️ There were merge conflicts (could not merge raoulb/more_distributions (a24f147ea86cc4984c01d969da4f1a6270d9ec11) into master (57e94e4)); could not test the branch.
@raoulb: Please rebase or merge your branch with master. See the report for a list of the merge conflicts.

@raoulb
Contributor
raoulb commented Dec 28, 2012

Is this ready for merge?

@mrocklin mrocklin commented on an outdated diff Jan 19, 2013
sympy/stats/tests/test_continuous_rv.py
@@ -1,14 +1,18 @@
from sympy.stats import (P, E, where, density, variance, covariance, skewness,
- given, pspace, cdf, ContinuousRV, sample,
- Arcsin, Benini, Beta, BetaPrime, Cauchy, Chi, Dagum,
- Exponential, Gamma, Laplace, Logistic, LogNormal,
- Maxwell, Nakagami, Normal, Pareto, Rayleigh,
- StudentT, Triangular, Uniform, UniformSum, Weibull,
- WignerSemicircle)
+ given, pspace, cdf, ContinuousRV, sample
@mrocklin
mrocklin Jan 19, 2013 Member

Missing a comma here.

@mrocklin
Member

I'm playing with sympy.stats again. It'd be nice to get this in before I make substantial changes. I've commented next to a trivial syntax error in the test file.

@mrocklin
Member

Also, I'm curious if there was a reason why you haven't implemented ChiSquared? You have Chi and ChiNonCentral but my understanding is that ChiSquared is used more often than either.

@mrocklin
Member

I ask just because I'm about to do it and was wondering if there was a reason why it was skipped. (My knowledge of distributions is very small).

@raoulb
Contributor
raoulb commented Jan 19, 2013

Also, I'm curious if there was a reason why you haven't implemented ChiSquared? You have Chi and ChiNonCentral but my understanding is that ChiSquared is used more often than either.

I think the reason was we can get if from \chi easily: let X ~ \chi^2_k then \sqrt{X} ~ \chi_k.
But maybe you are right and we should add it too, at least for the reason that users do not miss it.

@raoulb
Contributor
raoulb commented Jan 19, 2013

I'm playing with sympy.stats again. It'd be nice to get this in before I make substantial changes.

Yes, let's merge this one.
What are your new plans for the stats module?

BTW: The pattern/rule based RV-simplifier is a great project! But I doubt that I find time working on it.

@mrocklin
Member

The simplifier is the main point. Sympy.stats will require some general refactoring before it's ready though.

Sorry to hear you're busy. You're quite a force. I still hold out hope that I'll be able to attract you to write down rewrite rules once they're easy to do.

I'll merge in a bit.

@mrocklin mrocklin commented on an outdated diff Jan 19, 2013
sympy/stats/crv_types.py
+ ==========
+
+ k : Integer, `k` > 0 the number of degrees of freedom
+
+ Returns
+ =======
+
+ A RandomSymbol.
+
+ Examples
+ ========
+
+ >>> from sympy.stats import ChiSquared, density, E, std
+ >>> from sympy import Symbol, simplify, combsimp
+
+ >>> k = Symbol("k", integer=True)
@mrocklin
mrocklin Jan 19, 2013 Member

Looks like we might need positive=True as well

@mrocklin mrocklin commented on an outdated diff Jan 19, 2013
sympy/stats/crv_types.py
+
+ >>> from sympy.stats import ChiSquared, density, E, std
+ >>> from sympy import Symbol, simplify, combsimp
+
+ >>> k = Symbol("k", integer=True)
+
+ >>> X = ChiSquared("x", k)
+
+ >>> density(X)
+ Lambda(_x, 2**(-k/2)*_x**(k/2 - 1)*exp(-_x/2)/gamma(k/2))
+
+ >>> combsimp(E(X))
+ k
+
+ >>> simplify(expand_func(variance(X)))
+ >>> 2*k
@mrocklin
mrocklin Jan 19, 2013 Member

remove >>>

@mrocklin mrocklin commented on the diff Jan 19, 2013
sympy/stats/crv_types.py
+ ========
+
+ >>> from sympy.stats import ChiSquared, density, E, std
+ >>> from sympy import Symbol, simplify, combsimp
+
+ >>> k = Symbol("k", integer=True)
+
+ >>> X = ChiSquared("x", k)
+
+ >>> density(X)
+ Lambda(_x, 2**(-k/2)*_x**(k/2 - 1)*exp(-_x/2)/gamma(k/2))
+
+ >>> combsimp(E(X))
+ k
+
+ >>> simplify(expand_func(variance(X)))
@mrocklin
mrocklin Jan 19, 2013 Member

expand_func needs to be imported

@raoulb
raoulb Jan 19, 2013 Contributor

Oh, right. I had to add it when I tried this in ipython first and then forgot to put it into the docstring as well.
It turned out I forgot to run the doctests, there are some more missing imports and typos.

@raoulb
Contributor
raoulb commented Jan 19, 2013

SymPy Bot Summary: 🔴 Failed after merging raoulb/more_distributions (4f3ea61) into master (623aead).
@raoulb: Please fix the test failures.
🔴 Python 2.7.3-final-0: fail

@raoulb
Contributor
raoulb commented Jan 19, 2013

Some more unrelated bot failures

@raoulb
Contributor
raoulb commented Jan 19, 2013

Let's wait for travis and then merge

@mrocklin mrocklin merged commit 143860f into sympy:master Jan 19, 2013

1 check passed

default The Travis build passed
Details
@mrocklin
Member

Merged.

@raoulb raoulb deleted the raoulb:more_distributions branch Mar 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment