The universe of FiniteSet is not well defined. The class fulfills two roles
at the same time (this is bad).

It must interact with Intervals on the real line, so, for example we want
FiniteSet(1).complement == (-oo, 1) U (1, oo)

But FiniteSets are also used to hold arbitrary objects like FiniteSet(1, 2,
'cow'). In this case the universe is implied to be larger. This is not
clean, but has not yet caused problems (Sets are not used much.)

If you are interested in discrete probability then I suggest SymPy's finite
random variables in the development branch under sympy.stats. This is a way
to assign probabilities to elements in a FiniteSet and then ask probability
questions about them.



On Wed, Apr 18, 2012 at 9:15 PM, Kjetil brinchmann Halvorsen <
kjetil1...@gmail.com> wrote:

> thanks!  see below.
>
> On Wed, Apr 18, 2012 at 15:47, krastanov.ste...@gmail.com <
> krastanov.ste...@gmail.com> wrote:
>
>> It would be a strain to say that sympy has a nicely abstracted rule
>> set. In most of the code all such rules are just a part of the logic
>> of the methods of the class in question.
>>
>> For example (a+a) ---> 2*a is just part of the Add __new__ method.
>> When you call Add(a,a) it would apply appropriate rules and give you
>> Mul(2,a).
>>
>> There is occasionally discussion about abstracting better such rules,
>> but this is not yet done.
>>
>> So if you want an object that simplifies automatically in a certain
>> way, just implement the rules in the __new__ method or a helper
>> function and you will be good to go. It is not the cleanest solution,
>> but is how most of the stuff is done at the moment.
>>
>> I hope that this answers you question.
>>
>> BTW, there is a statistics module that implements many useful idioms
>> from probability theory and there is a set class that will definitely
>> can be extended if you are interested in helping.
>>
>
> Looking into this. For now, most interested in FiniteSet, usefull for
> discrete probability.
> But to be usefull, a part of the definition of a FiniteSet should be its
> Universe, I cannot see it is
> that now. How should that be done? Extending the definition, as it is now,
> or
> assum that the user defines a superclass of FiniteSet (not sure about the
> Python terminology here...)
> in a certain way?
>
> Kjetil
>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To post to this group, send email to sympy@googlegroups.com.
>> To unsubscribe from this group, send email to
>> sympy+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/sympy?hl=en.
>>
>>
>
>
> --
> "If you want a picture of the future - imagine a boot stamping on the
> human face - forever."
>
> George Orwell (1984)
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to sympy@googlegroups.com.
> To unsubscribe from this group, send email to
> sympy+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to