[SciPy-dev] arithmetic on distributions
rkern at ucsd.edu
Wed Aug 10 18:45:13 CDT 2005
Perry, Alexander (GE Infrastructure) wrote:
>>Perry, Alexander (GE Infrastructure) wrote:
>>>First suggestion. When calling an object to freeze it,
>>>if the loc is already a distribution, we should merge
>>>its variance into the variance of the newly frozen
>>>distribution [...] Currently, an error is triggered.
> From Robert Kern:
>>I think most people would simply conclude that
>>passing in a frozen distribution doesn't work
>>(especially since it is certainly not documented to do so).
> I _know_ it doesn't work and is nowhere documented as working.
> That's why it is a suggestion for improvement (not a bug report).
I was expanding on my comment (which you're responding to separately
later) that I can't imagine why someone would bother doing a try:
except: "to keep going" as it were when they should naturally conclude
that it just doesn't work at all and shouldn't be putting frozen
distributions as arguments.
>>>Because of the difficulty of merging the standard deviation
>>>of the old value into the new desired standard deviation,
> You didn't comment on this assertion, but then disagreed below.
> The code inside the wrapper is not particularly clean or obvious,
> since norm() expects a stdev, yet stats() returns the variance.
> #! /usr/bin/python
> from scipy.stats.distributions import norm
> from math import sqrt
> # Proposal, written as a wrapper
> def normal(loc,scale,**args):
> loc,locvar = loc.stats()
> scale = sqrt ( scale*scale+locvar )
> return norm(loc,scale,**args)
> # Two different early constants
> n1 = 10
> n2 = norm(n1,3)
> # Lots of code later
> print normal(n1,4) .stats()
> print normal(n2,4) .stats()
>>>I suspect that most people who encounter the error will take the
>>>lazy way out and simply discard the variance attached to the value:
>>>except: pass # the above is wrong!
>>I can't imagine why.
> It's wrong because I quietly discarded the distribution.
> It was presumably present on that variable for a reason,
> and I only did it to make the subsequent setup call work.
My statements make a little more sense if they're kept in order. I can't
imagine why someone would "take the lazy way out" when the code simply
I'm afraid I don't understand any of this conversation anymore if I ever
did. Can you try again from the beginning?
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the Scipy-dev