Random Numbers

\(Needs["Graphics`Master`"]; 
Needs["Calculus`Master`"]; \)

Random Numbers

The next command produces a "random" real number between 0 and 1:

Random[]

Random[Real, {-5, 5}]

The next command produces a "random" integer 0 or 1:

Random[Integer]

Random[Integer, {0, 100}]

An Example: Monte-Carlo for π

\(s = SessionTime[]; 
pts = Table[{Random[Real], Random[Real]}, {5000}]; 
    
res = Map[Function[s, Floor[s[\([1]\)]^2 + s[\([2]\)]^2]], pts]; 

    4. \((Length[res] - Apply[Plus, res])\)/Length[res]\)Print[SessionTime[] - s, "\tSeconds"]

Etc

Helmut Knaust, email: helmut@math.utep.edu. Created 2-23-1999.