ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 30 Oct 2012 16:21:49 +0100Best way to handle probability distributionshttps://ask.sagemath.org/question/9480/best-way-to-handle-probability-distributions/I'm curious to know what people recommend as the best way to handle probability distributions in Sage. Using scipy requires setting up a lambda function when doing a plot, and RealDistribution only accepts one parameter (standard deviation) for the normal distribution when there should be two. Is there a better option?Sun, 28 Oct 2012 23:15:51 +0100https://ask.sagemath.org/question/9480/best-way-to-handle-probability-distributions/Comment by kcrisman for <p>I'm curious to know what people recommend as the best way to handle probability distributions in Sage. Using scipy requires setting up a lambda function when doing a plot, and RealDistribution only accepts one parameter (standard deviation) for the normal distribution when there should be two. Is there a better option?</p>
https://ask.sagemath.org/question/9480/best-way-to-handle-probability-distributions/?comment=18782#post-id-18782It is possible to use the normal with a different mean, by just moving all the data - in fact, I think we showed that in the PREP workshop at some point. Obviously that's not optimal, though - maybe you should open a ticket? Just sayin' :-)Tue, 30 Oct 2012 16:21:49 +0100https://ask.sagemath.org/question/9480/best-way-to-handle-probability-distributions/?comment=18782#post-id-18782Answer by niles for <p>I'm curious to know what people recommend as the best way to handle probability distributions in Sage. Using scipy requires setting up a lambda function when doing a plot, and RealDistribution only accepts one parameter (standard deviation) for the normal distribution when there should be two. Is there a better option?</p>
https://ask.sagemath.org/question/9480/best-way-to-handle-probability-distributions/?answer=14211#post-id-14211[`scipy.stats`](http://docs.scipy.org/doc/scipy/reference/stats.html) seems quite full-featured, although I've only used [`rv_discrete`](http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_discrete.html#scipy.stats.rv_discrete) myself. You can define a new distribution as a subclass of `rv_continuous` or `rv_discrete`, and give it methods for the density, cumulative distribution, and many other things.
You should probably also look at R.Tue, 30 Oct 2012 08:39:18 +0100https://ask.sagemath.org/question/9480/best-way-to-handle-probability-distributions/?answer=14211#post-id-14211