• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Moderated Coin Flipper

Version 2:
Code:
<script id="worker2" type="javascript/worker">
      onmessage = function (e) {
         //console.log("Worker: Message received from main script", e.data[0]);
         let resultT = 0;
         let resultH = 0;
         let count = parseInt(e.data[0]);
         if (isNaN(count)) count = 1000;
         if (count > 10000000) count = 10000000;
         if (count < 10) count = 10;
         const myArray = new Int32Array(4);
         for (let i = 0; i < count; i++) {
            crypto.getRandomValues(myArray);
            const flip = myArray.reduce((a, b) => {
               return a + b;
            }, 0);
           [HILITE]if (flip > 0) resultH++;[/HILITE]
           [HILITE]else if(flip<0) resultT++;[/HILITE]
         }
         //console.log("Worker: Posting message back to main script", count);
         postMessage([resultH, resultT]);
      };
   </script>

Version 1:
Code:
   <script id="worker1" type="javascript/worker">
      onmessage = function (e) {
         //console.log("Worker: Message received from main script", e.data[0]);
         const result = e.data[0] * e.data[1];
         let resultT = 0;
         let resultH = 0;
         let count = parseInt(e.data[0]);
         if (isNaN(count)) count = 1000;
         if (count > 10000000) count = 10000000;
         if (count < 10) count = 10;
         for (let i = 0; i < count; i++) {
            [HILITE]if (Math.random() >= 0.5) resultH++;[/HILITE]
            [HILITE]else resultT++;[/HILITE]
         }
         //console.log("Worker: Posting message back to main script", count);
         postMessage([resultH, resultT]);
      };
   </script>

Leumas, if your version 2 app allows for an edge-landing, then your version 1 app is, incorrectly, counting edge-landings as heads. Alternatively, neither version allows for an edge-landing. Which is it?
 
Edited by jimbob: 
quote of subsequent -moderated content

Are you ever going to answer a simple question about your code, or are you going to dodge?

If you don't answer the question I just posed, here, I'll take your silence to mean you don't know the answer. But that, itself, doesn't matter, because either way, one of your two versions is not doing what you claim.
 
Last edited by a moderator:
Edited by jimbob: 
quote of subsequent -moderated content

A good programmer explains their code and acknowledges bug reports. A bad programmer lashes out with non sequiturs any time someone looks at their code with a critical eye.

Really, nowadays a good programmer just posts their code on github, and invites interested parties to try it for themselves and give feedback.

A bad programmer tries to keep their code to themselves, and cries "hax!" when their amateur hour attempt at security through obscurity absolutely craps the bed.
Q.E.D.
 
Last edited by a moderator:
Now do you see how it is all nothing but a red herring?
Maybe but you brought the whole argument on yourself.

You could have simply said that you have no intention of allowing for edge cases (irrelevant) or pointed out that your version 2 allows for edge cases but doesn't display them.
 
Leumas, if your version 2 app allows for an edge-landing, then your version 1 app is, incorrectly, counting edge-landings as heads. Alternatively, neither version allows for an edge-landing. Which is it?
IDK about version 2 but version 1 doesn't allow for any edge cases. Math.random() returns a double real number with the range 0 < x < 1.

Exactly half of all the possible results will fall withing the range 0 < x < 0.5 and the other half within the range 0.5 < x < 1.
 
Maybe but you brought the whole argument on yourself.


No I did not... When one's main CONCERN is to waft red herrings... little details like reading posts or testing things is not exactly in one's CONCERN.

As evinced below...

You could have simply said that you have no intention of allowing for edge cases (irrelevant) or pointed out that your version 2 allows for edge cases but doesn't display them.

That is precisely what I did... I never said that V1 allows for the edge case...

The whole edge Red Herring was started off in this post.

And then more concerns were stated in this post about the PRNG engine...

So IN RESPONSE

OK... I took your remarks into consideration... although the quick (time wise) PRNG I was using is VERY good indeed... but I agree it is not THE BEST.

Accordingly... to address your point I made a new version of the app Coin Flipper 2

Now I am using a Cryptographic algorithm.....

I also forgot to add... in Coin Flipper 2 I took account of the edge landing... I am not reporting it in the data but it is accounted for by not being a heads or tails in the final count of those. Although while I was doing testing of the algorithm I never encountered even one occurrence of this... but I only did a few hundred test only... it is indeed a very low probability. Maybe in V3 I might add a mechanism for reporting it if it occurs.


ETA: also see this post.

ETAA: see how it is admitted that they had code to see all along... despite demanding I give it to them and claiming I am liar until I genuflect to their CONCERNS.

Nobody "hacked" your code. That code is visible to anyone with a single click.


.
 
Last edited:
IDK about version 2 but version 1 doesn't allow for any edge cases. Math.random() returns a double real number with the range 0 < x < 1.

Exactly half of all the possible results will fall withing the range 0 < x < 0.5 and the other half within the range 0.5 < x < 1.


:bigclap


Eaxactly V1 did not take the edge claptrap red herring into account because I think it is utterly immaterial and does not in any way matter to the binary random distribution.

But in my naivete I wanted to alleviate the CONCERNS about the quality of the PRNG so I made V2 and in the process I also added allowance for the pointless red herring CONCERN about edge cases.

But of course as I said... when one's CONCERN is to waft red herrings, details and facts are of no CONCERN.

ETA: here are vivid examples of how the ever shifting CONCERN Goal Posts are zigged and zagged in order to keep the red herrings wafting...

Concerns about Edge landings... and when addressed... PRNG not good... and when addressed... Mechanics and REAL coins are not used in the computer.... then demanding to see my code or else I am a liar despite later admitting that they had the code all along by the click of a mouse.

Right...right, I get all that. Let me clarify:

1. The app claims to be a coin flipper. Obviously, it's not. It's a program that presumably thinks it's generating a random outcome of two (and in V2, 3) possibilities. Exactly how it is simulating this is crucial to interpreting the output data, which I doubt has anything whatsoever to do with the mechanics of a physical coin flip by a human.

In and of itself, reliance on cryptographic methods doesn't make a pseudorandom number sequence any more or less random. For more insight to the types of statistical tests a pseudorandom number generator should pass, I refer you to Donald Knuth's classic, The Art of Programming, Volume 2.

Ironically, that is what a good pseudorandom generator must do. Leumas' trials speak to the quality of the generator he is using and nothing at all to how coins behave.

I think there's a distinction between being able to pseudorandomly simulate some natural phenomenon, to a close enough approximation for some practical purpose...

... And believing that your pseudorandom simulation tells you accurately and precisely how that natural phenomenon actually works in nature.

Your pseudorandom two-case coin flipper certainly seems adequate for a wide range of dispassionate selector applications in the real world. But we shouldn't be fooled into thinking it's an accurate description of the underlying physics that produce probabilistic binary results in some natural system.

...
But without seeing the generator, you could have made an app that outputs percentages that are closer to 50/50 as trial sizes are increased, and has nothing whatsoever to do with actual coin flipping odds. It may simply be a program which will never read 50%, but always a small percentage off.

In case it isn't clear to anyone by this point, Leumas's version 2 does not allow for the possibility of an edge-landing, as he claimed.

I've never met a good software developer that wasn't happy to describe the details of their implementation at the slightest sign of interest.

Nobody "hacked" your code. That code is visible to anyone with a single click.

Are you ever going to answer a simple question about your code, or are you going to dodge?

If you don't answer the question I just posed, here, I'll take your silence to mean you don't know the answer. But that, itself, doesn't matter, because either way, one of your two versions is not doing what you claim.
 
Last edited:
ETAA: see how it is admitted that they had code to see all along... despite demanding I give it to them and claiming I am liar until I genuflect to their CONCERNS.

Well, that is a bit of an overstatement (multiple in fact).

You were asked about how you modeled the "edge case". The question was about logic and reasoning that went into your model. Someone's code is usually an awful way to derive someone's logic and reasoning going into model construction.

As for the claim that you were a liar, that is a conclusion derived from seeing the actual code.
 
@ Leumas: Well, I think people are just genuinely confused as to what you want to show with your experiment, and how the experiment is supposed to show it, and when they tried to engage you on some finer points, you responded belligerently, so everyone doubled down and now here we are.
 
ok, Leumas, you're under fire already, and I don't really want to add to it. And this is so very obvious that it doesn't need saying I suppose. On the other hand, it is so very obvious, that is precisely why I'm curious how come you don't grok this, despite more than one poster pointing this out --- certainly your BFF Thermal did that, multiple times, but some other posters did that as well. So I'm wondering if perhaps you meant something else after all, and that's all I mean to get you to clarify, is all. Don't take this as yet another barrage fired at you, please.

Regardless of which set of random numbers you use, and regardless of what kind of model you use, and what kind of app you use to fire up your model: Your results will speak to you your app itself, and to the random numbers you've used. How does that say anything at all about actual coin tosses? That's so completely and obviously circular, isn't it?

Yes, models are used all the time. But they're used to explore questions about the system beyond assumptions that went into the model itself. Unlike here. Here you're assuming coin tosses correspond to your model, and are approximated by whatever random array you're using; and then using the results to show (or, at any rate, to try to show) that you actually do get randomness. How could it show any different, given the complete and obvious circularity of it all? All that this tests is whether your chosen set of would-be random numbers do approximate randomness, and whether your app itself is sound.

Or did you, by any chance, mean to do or convey something else?
 
@ Leumas: Well, I think people are just genuinely confused as to what you want to show with your experiment, and how the experiment is supposed to show it, and when they tried to engage you on some finer points, you responded belligerently, so everyone doubled down and now here we are.

#MissionAccomplished
 
...
Or did you, by any chance, mean to do or convey something else?


OK Chanakya... did you read the OP??

Here it is with some emphases added so that maybe you can glean the answer to your above question

...
An individual atom decays unpredictably. Yet we can predict the decay of a large set of atoms. A single coin toss produces an unpredictable result. But we can predict the approximate results of ten thousand coin tosses. Now, is this random?


The above post led me to write a little WebApp to play with to see the result of coin tosses varying from 10 at a time to 10,000,000 at a time....


Now... just to clarify the matter a little more....

What will be your answer to this


...
An individual atom decays unpredictably. Yet we can predict the decay of a large set of atoms. A single coin toss produces an unpredictable result. But we can predict the approximate results of ten thousand coin tosses. Now, is this random?



Is it random? Why or why not? How do you know?

Have you ever tossed a coin 10,1000 times and figured out the results?

Or did you arrive at the answer to acbytesla's question just by assuming things that you never verified for yourself?

Now... hmmmm... what can you use to verify the randomness of coin tosses whether 10,000 or 10,000,000?

Let's say that it takes you 10 seconds to toss a coin and look at it record the result and bend over, pick it up and REPEAT...

So to answer acbytesla's question you will need to do that 10,000 times... but... not just once AT LEAST twice... no?

So that is 200,000 seconds at the very least and to be really fair you might have to actually do it more.

That is ~55.6 hours of continuous uninterrupted 10 seconds after another.

Can you do that?

So you can never verify acbytesla's question can you?

Hmmm... or can you.... hmmm... how oh how could you do 20,000 coin tosses or even more without killing yourself?

Hmmm???:confused:
 
Last edited:
OK Chanakya... did you read the OP??

Here it is with some emphases added so that maybe you can glean the answer to your above question




Now... just to clarify the matter a little more....

What will be your answer to this






Is it random? Why or why not? How do you know?

Have you ever tossed a coin 10,1000 times and figured out the results?

Or did you arrive at the answer to acbytesla's question just by assuming things that you never verified for yourself?

Now... hmmmm... what can you use to verify the randomness of coin tosses whether 10,000 or 10,000,000?
Let's say that it takes you 10 seconds to toss a coin and look at it record the result and bend over, pick it up and REPEAT...

So to answer acbytesla's question you will need to do that 10,000 times... but... not just once AT LEAST twice... no?

So that is 200,000 seconds at the very least and to be really fair you might have to actually do it more.

That is ~55.6 hours of continuous uninterrupted 10 seconds after another.

Can you do that?

So you can never verify acbytesla's question can you?

Hmmm... or can you.... hmmm... how oh how could you do 20,000 coin tosses or even more without killing yourself?

Hmmm???:confused:


That many coin tosses.

See that post of mine, just above yours, and that you quoted from. Doing this a few hundred times may be tiresome, doing this thousands of times might be not very easy, and in any case doing it even a few million times might not be completely 100% conclusive --- although I'd argue that such large numbers would be close enough to generalize about, after all that's what we do all the time, and also, plenty of more substantial experiments and observations are difficult and time-consuming and all of that, so there's that as well --- but, in any case, I don't see how going for a circular argument helps.

Not to beat this to death. Went through this thread, and wondered if you might have had something else in mind, maybe. Don't mind me, carry on.
 
...
Not to beat this to death. Went through this thread, and wondered if you might have had something else in mind, maybe. Don't mind me, carry on.


It usually helps to read the OP.

But what is your answer to acbytesla's question?

Moreover... do you think randomness is an illusion and there is no randomness that is inherent in the natural world?
 
It usually helps to read the OP.

I got you Chanakya. The OP is four short paragraphs. Here's the synopsis:

P1. Leumas is inspired to write an app prompted by another poster's musing on probability.

P2. Leumas briefly describes the apps exciting features, mostly consisting of endlessly flipping coins.

P3. Leumas makes confidently incorrect claims about the results that the app would produce.

P4. Leumas talks about historically slow processing speeds on his devices.

Now tell me, what the **** are we supposed to get from that disjointed mess?

But what is your answer to acbytesla's question?

Moreover... do you think randomness is an illusion and there is no randomness that is inherent in the natural world?

See dat? Nothing to do with the OP. Leumas playing the backdoor game.
 
Here's my "app," "Coin Flipper R," ver. 0.

Code:
sum(rbinom(n=10000, 1, .5))

Here are the results (number of "heads") of running it 5 times, with the number of flips n=10,000.
Code:
5045
5055
4965
4997
4924

Alas, it runs in the console and not on the web, like Leumas's. On the other hand, it is exactly one line of code, not 200, like Leumas's.

Sorry, Leumas, but all you've done is write 199 lines of literal window dressing to implement a one-line program that does nothing more than illustrate the consequences of an elementary probability theorem that was proved over 300 years ago.
 
Last edited:
Moreover... do you think randomness is an illusion and there is no randomness that is inherent in the natural world?
I'm afraid that your app won't answer that question.

Even fully deterministic systems can be modeled with random numbers. In fact, this may be the only way to move forward if you don't have all of the necessary measurements to deal with the system otherwise.
 
Are you going to answer the questions I asked you below?


Sure, Leumas, if you insist.

Not that I've anything remotely significant to add, which is why, and like I'd said, I'd not responded the first time you asked.

Your two questions:


But what is your answer to acbytesla's question?


acbytesla's question (the portion you've quoted in your OP) was: "A single coin toss produces an unpredictable result. But we can predict the approximate results of ten thousand coin tosses. Now, is this random?"


Yes, a single coin toss produces an unpredictable result.

And yes, we can predict the approximate result of a large number of tosses.

Also, yes, I guess individual tosses would be random, because QM.

(But no, I don't see this has anything to do with your app.)

(And, to tie this back to that other thread: No, neither case, neither randomness, nor its obverse, indicates ID.)


Moreover... do you think randomness is an illusion and there is no randomness that is inherent in the natural world?


Basis my layman's very limited and entirely fallible understanding of QM, no.

To spell it out, no, I don't think randomness is an illusion, and yes, I do think you come across randomness in the natural world.

(And again, I don't see how this has anything to with your app. And also, none of this in any way indicates ID.)
 

Back
Top Bottom