cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

Emerald II

I think the rnd function (a procedure) in Mathcad is not so good

What can you say about it?

and this two pictures:

Coin

Dice

24 REPLIES 24

 Valery Ochkov wrote:I think the rnd function (a procedure) in Mathcad is not so good

Why do you think so?

What did you expect for the coin toss? Precisely 50%???

The probabilty that with 10^7 tosses you get exactly 50% heads is just about 0.025% so I wouldn't trust the random number generator if it would yield exactly 50% most of the times.

On the other hand - the probability that the percentage of heads up is inbetween 49.95% and 50.05% for 10^7 tosses is as high as 99.84% and that fits perfectly to the result you achieved.

EDIT: The coin toss routine could be written much more compact

I think the point must go to the line at n-> infinity.

 Werner Exinger wrote:Valery Ochkov wrote:I think the rnd function (a procedure) in Mathcad is not so good Why do you think so?EDIT: The coin toss routine could be written much more compact

Sorry more compact but not so simple for an understanding

 Valery Ochkov wrote:See please the animation.I think the point must go to the line at n-> infinity.

For n->infinity, yes. For n=10^5 not necessarily.

But its disturbing the the calculated value is always too high.

But then, we don't see how the random numbers are generated and how it is decided if a point is inside.

BTW, I have programmed that Monte Carlo pi finding quite a number of times using different programming labguages and different compilers and it was somewhat disappointing every time. Its a very slowly converging method.

Sorry more compact but not so simple for an understanding

Thats true, but your point was to prove that the randon number generator in Mathcad does not work to your expectation and not to provide a sample program to be used in a basic programming course, right?

Interested in another harder to understand routine?

Of course we can compact that too:

The drawback of both routines is that a full vector is generated first hand and there is a (memory) limitation for creating vectors which prevents using much larger numbers for n than those given in the screenshots.

Thanks, Werner!

I would like to translate into English my article "Tripartite duel in Monte Carlo" from the Magazine "IT in school".

The rnd routine is the main point of the article!

The begin of the article

There is one joke. Student wakes up every morning and thinks of throwing a coin, "the winning eagle - will sleep more on the right side, rolled tails - lie on your left side, on the edge of the coin will fall - go to college, and hangs in the air - 'll coursework."
Joking aside, we often have to toss a coin - real or virtual , to randomly select one of two equally likely possibility . Football referee, for example, before the match is flipping a coin to determine which team to give certain gates. Chess player before the game in one hand grips the white pawn and the other - black and offers an opponent choose "one of two equally likely possibility" - to determine who will play the white pieces , and who - black . Shuffling a deck of cards or dominoes stirring, again we give ourselves to chance. And from this , the will of the case may depend very much... Even the person's life, if you remember the title of this article. And why not a simple ( two-sided ), and unusual ( tripartite ) duel, and even in Monte Carlo!? The fact that the problem of the tripartite duel is described in many books , such as [1, 2 ], which provides one of the particular solutions of this problem , obtained by logical reasoning . We consider a more complete solution to this problem on a computer Monte Carlo ( Monte Carlo method ) : simulate a single duel , spend quite a lot of her time and calculate the number of wins in these duels each participant [3]. If these numbers are divided by the total number of duels, and the result will be the desired probability victories.
But we begin with simple tasks bezkompyuternoe decision known.
Let us remember our lackadaisical student from a joke, using a computer to flip a coin many times and count how many times the winning eagle, and how much - tails. Fig. 1 shows the corresponding computer program - OrelIliReshka function with argument n (number of tosses of a coin), which returns the probability of coming up heads or tails .

I cannot duplicate the problem/error your animation shows but without seeing the code we cannot tell if there is an error in the sheet or what else could cause that effect.

At least I reproduced the Monte Carlo calculation of Pi and see a slow but good convergence.

See below some screenshots from different runs in a log scale.

An animation using a linear scale is here: http://communities.ptc.com/videos/4527