On Sat, Oct 29, 2011 at 8:11 AM, David Joyner <[email protected]> wrote:

> On Sat, Oct 29, 2011 at 11:09 AM, michel paul <[email protected]> wrote:
> > Here's a relatively minor issue that might not be minor for someone new
> to
> > Sage.
> > In illustrating very simple probability as
> len(outcomes)/len(sample_space),
> > integer division occurs, so the probability becomes 0.
>
>
> Can you give a specific example please?
>

Sure - typical simple intro - throwing two dice:

S = [(die1, die2) for die1 in [1..6] for die2 in [1..6]]
E = [throw for throw in S if sum(throw) == 7]

len(E)/len(S) will produce 0.  We can very easily use 1.0*len(E)/len(S), or
we can use Integer(len(E))/len(S).  I prefer the latter.  Either way, a
student response will be, "Why do we have to do that here?"

- Michel


> Easy enough to correct - but it prompts discussion of why do we even have
> to
> > bother with that?
> > In a class where we're interested also in pure bare bones Pythonic
> > expression of ideas, this provides a nice example of how Python 2 and
> Python
> > 3 differ, but for classes not interested in programming per se, just in
> > 'math', it might be seen as a glitch.
>

-- 
==================================
"What I cannot create, I do not understand."

- Richard Feynman
==================================
"Computer science is the new mathematics."

- Dr. Christos Papadimitriou
==================================

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

Reply via email to