#9670: Bring probability/random_variable.py to 100% coverage
-----------------------------+----------------------------------------------
Reporter: kcrisman | Owner: mvngu
Type: enhancement | Status: new
Priority: major | Milestone: sage-5.0
Component: documentation | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
-----------------------------+----------------------------------------------
Comment(by was):
Some remarks from Tvrtko Tadic, a UW grad student in probability:
{{{
I don't think discrete probability
space needs to have an expectation (as a function).
It could be
for example that a kid gets an apple with probability 1/2,
and a orange with probability 1/2. We can't sum
half an apple and half an orange.
So I don't think the class DiscreteProbabilitySpace should
have an expectation method at all.
It could be that somebody started an expectation
method in the wrong class and the forgot about it.
I tried the expectation for DiscreteRandomVariable, and it works
fine. (Random variables take values in real numbers,
and the expectation is defined for them not for
probability spaces.)
EXAMPLE (DICE):
P=dict([(i,1/6) for i in [1..6]])
Omega=[1..6]
PS=DiscreteProbabilitySpace(Omega,P)
f=dict([(i,i) for i in [1..6]])
X=DiscreteRandomVariable(PS,f)
X.expectation()# (it should be 7/2)
X.variance() # (it should be 35/12)
It works!
I will take a look at the other packages Sage has
for probability (and related areas) that you mentioned.
Best,
Tvrtko
---
> Thanks - the original author of the code posted a long message to that
> ticket -- please look again.
I see, I still think that the expectation function
in the class probability space is confusing, it
will only confuse people.
I have also noticed that in these classes
you can't add add or multiply random variables
either by another random variable or by an number.
All of these operations give a random variable,
and it seems that this could easily be done.
I could, maybe do something like this for the final project,
make my class by adding new methods
to the one existing
and then we could see
what could be added to the class in Sage.
>Mind if I post your remarks there?
You can post my remarks.
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9670#comment:6>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.