
Show HN: Learn When to Quit - atum47
https://github.com/victorqribeiro/googol
======
ronilan
Madden: _" Now with no timeouts I think that the Patriots, with this field
position they have to just run the clock out, you have to play for overtime
now. I don't think you want to force anything here, you don't want to do
anything stupid because you have no timeouts and you are backed up."_

Summerall: _Brady is in the shotgun and he 's gonna throw it ..."_

[https://www.youtube.com/watch?v=GC4qgrUgF9I&feature=youtu.be...](https://www.youtube.com/watch?v=GC4qgrUgF9I&feature=youtu.be&t=51)

Always trust the stats ;)

~~~
ajushi
I don't get it sorry. How does this relate with the OP?

------
shaftoe
This is the Secretary Problem.

[https://en.wikipedia.org/wiki/Secretary_problem](https://en.wikipedia.org/wiki/Secretary_problem)

~~~
larnmar
Sometimes when I’m bored and out walking, I play this game with cars. I
pretend I’m allowed to keep any one of the next ten cars that go past, but I
need to accept or reject it the moment I see it.

If the second car is a Volvo do I pick it, or hold out waiting for a Mercedes?
If I pick that Mercedes, am I going to regret it in thirty seconds when a
Rolls rolls past? Am I going to get stuck with an old Hyundai due to my
inability to settle?

------
trisiak
The distribution of numbers is not uniform across the 0..googol here. The
implementation first chooses the length of the number, then fills in the
digits. This makes it biased towards smaller numbers.

Does it still have the same optimal strategy as for uniform generation?

~~~
atum47
>"The implementation first chooses the length of the number, then fills in the
digits. This makes it biased towards smaller numbers."

Why?

~~~
bentona
Semi-relevant:
[https://en.wikipedia.org/wiki/Benford%27s_law](https://en.wikipedia.org/wiki/Benford%27s_law)

~~~
atum47
People, I just ran this simple script on my terminal using Node and I got a
pretty uniform result.

    
    
      a = {}
      for(let i = 0; i < 100000; i++){
        let n = Math.floor(Math.random() * 10);
        if( n in a )
          a[n] += 1
        else
          a[n] = 1
      }
    
    
    

My result:

{ '0': 9917, '1': 10015, '2': 9957, '3': 10107, '4': 10019, '5': 10037, '6':
10120, '7': 9914, '8': 10042, '9': 9872 }

~~~
peteretep
> real-life sets of numerical data

Today you learned: Node’s random number generator isn’t selecting from a real-
life set of numerical data

~~~
atum47
yeah, I just mixed two informations. I thought the other person said my
algorithm would be biased towards small numbers cause I use the JS random
function to pick the number of decimal places for the number

~~~
bentona
Yep, sorry, didn't mean to say this directly applied, just a neat concept
that's somewhat related.

------
iakh
Consider using a monospace font. It is difficult to tell how large one number
is relative to another when each digit has a different width

~~~
cyode
Having a button to toggle on/off rounded e-notation (e.g. 1.2365479e+45) could
make comparison easier as well.

Nice job with this, I learned something new today :)

------
cjauvin
I have written a small analysis of that same problem using simple Python code,
a couple of years ago:

[https://cjauvin.blogspot.com/2012/12/find-true-love-on-
datin...](https://cjauvin.blogspot.com/2012/12/find-true-love-on-dating-site-
using.html)

~~~
leetrout
Nice work

------
sneak
All of these huge numbers are basically un-comparable ergonomically to me. Why
not make the distribution 1-10k instead?

~~~
hmexx
Agreed.

Also, there is really no reason to have multiple boxes you have to click. You
could just have a single "next" button along with a counter to show how many
choices you have left before you run out.

~~~
OJFord
Yeah that confused me too.

'Next' button along with '# samples left' display would be much clearer.

Also, if the largest drawn so far were highlighted, manual play would be
easier.

------
glaive123
I just did "Computer" 50 times and tallied the results.

Win = 32% Lose = 68%

But here's the thing, the goal should not be to win, but to get ONE OF the
highest numbers with reliability.

Now here's where Optimal Stopping Theory is not optimal.

42% of the time you lose by getting to the end. Meaning you drew all 50 cards
and ended with likely a very small card.

The goal of this algorithm should be that you almost never get to drawing the
50th card. You always stop before then and end with a high number.

Therefore, I wouldn't consider this algorithm optimal. Likely you should draw
fewer cards in the beginning.

------
curo
How does this change when you're heavily punished for ending up with a much
lower number (e.g., in finding a partner, biz deal, etc)?

Among a set of losing plays, I presume it's 50/50 on whether you turn over
every card (and end up with the last one). So a third of the time you end up
in the optimal case, another third you end up doing pretty well, and another
third you're subject to absolutely random chance. Guess this is an argument
for satisficing vs optimizing in most real world applications.

~~~
repsilat
You're right, this algorithm optimizes for "1 point for picking the best
option, 0 for anything else", not knowing the distribution.

If you _do_ know the distribution, and have some objective function, and
samples are "free", you get a different model that you can solve inductively
backwards from the case of "the last sample".

A different model is that your objective function is still on order, but it
gives some points for "closer to best". Maybe you score minus n for picking
the nth best sample. In that case the model need not have a known distribution
(It's different if you do or don't.) And the strategy us different: if the
99th sample out of 100 is the second best you've seen so far, you should take
it. (Which can't possibly be optimal in the original model.)

------
smabie
I don’t understand, could some one explain? What am I trying to do in this
game? And how do I win?

~~~
atum47
Did you watch the video? It does a very good job explaining the theory tested
on the game.

------
whack
There is a huge problem with the "optimal stopping strategy" presented in the
YouTube video: _" sample the first 37% of the options, and then choose the
first subsequent option that is better than the best option found in the
sample."_

By definition, there is a 37% chance of the best option being in your initial
sample. You would then futilely browse through all the other options, without
ever picking anything.

Ie, if you applied this strategy to "finding the love of your life", as the
video suggests, there is a 37% chance of you dying completely alone. That
doesn't seem like a very optimal strategy to me.

~~~
spencey
I haven't seen the video but if they are talking about the secretary problem
the caveat is that you can't go back to the previous options. You can do that
when trying to a find a partner... sometimes.

------
h1fra
Very interesting, especially the video :pray:

(actual game does not look at all like the screenshot on mac/chrome)

------
flurdy
For some reason, I thought this was about Vim...

~~~
atum47
:q!

------
rkagerer
Comma's would be friendlier than decimal groupings for North American users;
also right-aligning would be nice.

~~~
OJFord
The `.` separation confused me briefly too, being from another country that
uses `,`.

But you know what, if I were the author I would have used `,` without
bothering to localise to `.` (for some toy demo thing like this anyway) so I'm
OK with OP doing the same to me.

