Hello,

I play with random in order to approximate Pi by Monte-Carlo method.

sage: n=10^5 ; len(filter(lambda t:t, [random()^2+random^2() < 1 for k in [1..n]])) / len([1..n])

The test looks at the point (random(), random()) and tests if it's in the quarter circle.
The result may be about pi/4.

I get 0. Indeed the result of len is an int, not a Integer.

Must I retain that len(L) is a Python int ?
What is the advantage to get a Python int from len(L) ? What are the others cases ?
Is it a way to get an Integer whitout change of the syntax ?
I dislike the Integer(len(....)), and in tex I code lenORI = len ; len = Integer(lenORI))
Is there a method for Sage.

Many thanks for your advice.

François from France.

--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to