Show HN: Learn When to Quit
github.com
github.com
Summerall: Brady is in the shotgun and he's gonna throw it ..."
https://www.youtube.com/watch?v=GC4qgrUgF9I&feature=youtu.be...
Always trust the stats ;)
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?
The solution wouldn't be to still skip 1/e if you got something like googol - 1 on the first try.
Does it still have the same optimal strategy as for uniform generation?
This is not the same hypothesis as the problem stated in the video. The video talks about the "secretary problem". In this problem you know nothing about the distribution. You just know that the number are ordered.
Here because you know the distribution you can do better by using a strategy which choose to stop depending on the value of the number you have so far. For example if at the 15th pick you get a number with 99 digit, you can safely assume that it is better to stop now (every time you pick you have only a ~1% chance of finding a 99-digit number needed to do better so keeping it means you win (99/100)^(50-16) = 70%, whereas the non-exploitable strategy (i.e. optimal strategy for the secretary problem) 50/e=18 will tell you to keep going and you would lose 70% of the times).
For the secretary problem the theoretical way to sample the number is to set it up as a game where the first player plays the game and the second pick the numbers adversely so that the first doesn't win. A good strategy for the second player is to pick a distribution from a big set of varied distributions, and sample the number from this distribution.
(With a discrete distribution, the possibility of ties slightly affects things. But in this particular game, ties seem to be very improbable, so they can be ignored.)
Why?
Likewise with the full 100 digits this algorithm has a 1% chance of generating a number less than 10, while the correct proportion would be 1e-100.
The algorithm also does not generate numbers with zero in them (presumably to avoid leading zeroes, but this will skew results somewhat).
I think the correct algorithm would be to generate 100 digits and then remove the leading zeroes.
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 }
Today you learned: Node’s random number generator isn’t selecting from a real-life set of numerical data
Nice job with this, I learned something new today :)
https://cjauvin.blogspot.com/2012/12/find-true-love-on-datin...
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.
'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.
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.
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.
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.)
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.
I don't think that's correct. You'd set a period of time such as 1 year or 3 years or 5 years or something during which time you will go on n amount of dates total, out of which you reject the first 37%. Then you use that as a basis for the remaining time of that period of time. If you haven't found anyone better by the last date of that time, and you have chemistry with them, you choose that last person to be the love of your life.
And if you don't have chemistry with the last person or you end up breaking up with that person, then you go on dates until you find the next person you have chemistry with and you choose them to be the love of your life.
So it's not like dying completely alone is a probable outcome that would result from the optimal stopping strategy itself.
(actual game does not look at all like the screenshot on mac/chrome)
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.