Hi everyone,

I'm working on implementing random variables in SymPy. The goal is to have
them syntactically behave like normal variables but carry around more
complex information like symbolic probability density functions (PDFs). I
would like to be able to define X, a random variable and then define Y =
sin(X), another random variable with transformed PDF.

How should this be implemented? Should sin contain the logic to transform
the PDF of X? Should it identify that X is_random and then push the work off
someplace else? I'm hesitant to change anything too deeply in the core for
the benefit of a relatively unused module.

In an ideal world the operand (in this case the random variable X) would be
able to take control. This is the case for some functions like abs which
just call the object’s __abs__ method. I can’t find any evidence that this
is possible generally in the Python language although I’d be thrilled to
find that I was incorrect.

To achieve minimal disruption of the core I could always do something like
X.applyfunc(sin) but this seems unpleasant to write. I think that matrices
use this solution.  Another thought is to have elementary sympy functions
check for an applyfunc method of their arguments and, if it exists, to use
it. This would solve my problem and possibly be useful generally.


Any thoughts or ideas on solutions? What is the correct way to solve this
problem?

Best,
-Matt

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" 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/sympy?hl=en.

Reply via email to