How random are you?





  • Where's my cookie?

    26a0e5c1-18ea-486c-a9fc-e4617c8ea970-image.png


  • I survived the hour long Uno hand

    @mott555
    In either my 🤛 or 🤜, read my mind...



  • I literally generated a random sequence and the bot won 25:22



  • @CarrieVS Machine learning confirmed OP



  • @hungrier Well after that I played how you're intended to and won (just)


  • Discourse touched me in a no-no place

    d249ec56-2fa7-4da5-a581-48b2d2134254-image.png



  • @CarrieVS said in How random are you?:

    I literally generated a random sequence and the bot won 25:22

    well..... 25-22 is 47 trials., but i'll call it 50 just to make the math easier.

    with fifty trials the odds of getting all 50 correct are 1/2^50 or about 8.8E-16

    but the odds of getting 25 correct are....well..... 50/50, because there's 50 trials and a 50% change of getting it right each time...

    but don't take my word for it! Let's write some code to prove it!

    'use sanity'
    
    const columns = 40
    const trials = 1e6
    const rounds = 50
    const flips = () => Array(rounds).fill().map(() => Math.random() < .5)
    const compare = (a,b) => a.reduce((r, ai, i) => r + (ai == b[i] ? 1: 0), 0)
    const results = []
    for (let i = 0; i < trials; i++) {
        const index = compare(flips(), flips())
        results[index] = 1 + (results[index] || 0)
    }
    
    const modeiv = results.reduce((r, v, i) => v > r.v? {v, i} : r, {v : 0})
    const mode = modeiv.i
    const factor = columns / modeiv.v
    
    for (let i = 0; i < results.length; i++) {
        limit = Math.floor((results[i] || 0) * factor)
        if (!limit) {
            continue
        }
        console.log(`${(' '.repeat(5)+i).slice(-5)}: ${'*'.repeat(limit)}`)
    }
    
    const flatResults = results.flatMap((v, i) => Array(v).fill(i))
    const average = a => a.reduce((r, v) => r + v, 0) / a.length
    const stddev = a => {
        const avg = average(a)
        return Math.sqrt(a.reduce((r, v) => r + (v - avg) * (v - avg), 0) / a.length)
    }
    
    console.log(`Expected Number of Correct Guesses ${(0.5 * rounds).toFixed(3)}`)
    console.log(`Modal Number of Correct Guesses: ${mode}`)
    console.log(`Average Number of Correct Guesses: ${average(flatResults).toFixed(3)}`)
    console.log(`Standard Deviation: ${stddev(flatResults).toFixed(3)}`)
    
    
    VM429:22    16: *
    VM429:22    17: ***
    VM429:22    18: *****
    VM429:22    19: *********
    VM429:22    20: **************
    VM429:22    21: *********************
    VM429:22    22: ****************************
    VM429:22    23: **********************************
    VM429:22    24: **************************************
    VM429:22    25: ****************************************
    VM429:22    26: **************************************
    VM429:22    27: **********************************
    VM429:22    28: ****************************
    VM429:22    29: *********************
    VM429:22    30: ***************
    VM429:22    31: *********
    VM429:22    32: *****
    VM429:22    33: ***
    VM429:22    34: *
    VM429:32 Expected Number of Correct Guesses 25.000
    VM429:33 Modal Number of Correct Guesses: 25
    VM429:34 Average Number of Correct Guesses: 25.000
    VM429:35 Standard Deviation: 3.535
    


  • @Vixen

    'use sanity'

    In Javascript? :doing_it_wrong:



  • Also, omitting semicolons is definitely not using sanity



  • @hungrier said in How random are you?:

    @Vixen

    'use sanity'

    In Javascript? :doing_it_wrong:

    Yes. In JavaScript

    @hungrier said in How random are you?:

    Also, omitting semicolons is definitely not using sanity

    It's a valid code style. https://standardjs.com/

    It's a bit of an opinionated code style, but that doesn't make it less valid.


  • Discourse touched me in a no-no place

    @hungrier said in How random are you?:

    @Vixen

    'use sanity'

    In Javascript? :doing_it_wrong:

    Alanis Morissette called to discuss your wedding day. Something about the weather.


  • Discourse touched me in a no-no place

    @Vixen said in How random are you?:

    @hungrier said in How random are you?:

    Also, omitting semicolons is definitely not using sanity

    It's a valid code style. https://standardjs.com/

    It's a bit of an opinionated code style, but that doesn't make it less valid.

    Being in JavaScript makes it less valid 🎺



  • @loopback0 said in How random are you?:

    @hungrier said in How random are you?:

    @Vixen

    'use sanity'

    In Javascript? :doing_it_wrong:

    Alanis Morissette called to discuss your wedding day. Something about the weather.

    It's like 10000 spoons when all you need is a semicolon at the end of each line of code



  • @loopback0 said in How random are you?:

    @Vixen said in How random are you?:

    @hungrier said in How random are you?:

    Also, omitting semicolons is definitely not using sanity

    It's a valid code style. https://standardjs.com/

    It's a bit of an opinionated code style, but that doesn't make it less valid.

    Being in JavaScript makes it less valid 🎺

    926ce991-e75a-4925-bdfa-b9c2d6dff57e-image.png



  • mindreaderscore.png


  • Notification Spam Recipient

    @Zenith I was going to post my 18:25 but now I have something to strive for...


  • BINNED

    @Vixen said in How random are you?:

    but the odds of getting 25 correct are....well..... 50/50, because there's 50 trials and a 50% change of getting it right each time...

    You wrote a simulation to prove the expectation value of a binomial distribution? I mean, n*p isn't that hard to compute by hand.



  • @topspin said in How random are you?:

    @Vixen said in How random are you?:

    but the odds of getting 25 correct are....well..... 50/50, because there's 50 trials and a 50% change of getting it right each time...

    You wrote a simulation to prove the expectation value of a binomial distribution? I mean, n*p isn't that hard to compute by hand.

    yes, as it turns out I did just that.



  • @Vixen Mathematics confirmed



  • @hungrier said in How random are you?:

    @Vixen Mathematics confirmed

    once again. We may yet prove Einstein wrong, but Liebnitz is still an unassailable target.


  • Banned

    @Vixen said in How random are you?:

    Liebnitz is still an unassailable target.

    Unspellable too, it seems.



  • @GÄ…ska said in How random are you?:

    @Vixen said in How random are you?:

    Liebnitz is still an unassailable target.

    Unspellable too, it seems.

    E_INSUFFICIENT_CAFFEINE: ACCESS_TO_DICTIONARY_SUSPENDED


  • Banned

    @Vixen also E_GERMAN_NAMES_PRONUNCIATION_MODULE_NOT_FOUND, I presume.



  • @GÄ…ska said in How random are you?:

    @Vixen also E_GERMAN_NAMES_PRONUNCIATION_MODULE_NOT_FOUND, I presume.

    I mean, Imma fox. You're lucky I can pronounce any human names at all.



  • :trwtf: is every screenshot in this thread shows the bot losing to the user. :trollface:



  • @_P_ said in How random are you?:

    :trwtf: is every screenshot in this thread shows the bot losing to the user. :trollface:

    Self Selection Bias.

    people are a lot less likely to post their losses than their wins.



  • @Vixen said in How random are you?:

    @CarrieVS said in How random are you?:

    I literally generated a random sequence and the bot won 25:22

    well..... 25-22 is 47 trials., but i'll call it 50 just to make the math easier.

    with fifty trials the odds of getting all 50 correct are 1/2^50 or about 8.8E-16

    but the odds of getting 25 correct are....well..... 50/50, because there's 50 trials and a 50% change of getting it right each time...

    but don't take my word for it! Let's write some code to prove it!

    'use sanity'
    
    const columns = 40
    const trials = 1e6
    const rounds = 50
    const flips = () => Array(rounds).fill().map(() => Math.random() < .5)
    const compare = (a,b) => a.reduce((r, ai, i) => r + (ai == b[i] ? 1: 0), 0)
    const results = []
    for (let i = 0; i < trials; i++) {
        const index = compare(flips(), flips())
        results[index] = 1 + (results[index] || 0)
    }
    
    const modeiv = results.reduce((r, v, i) => v > r.v? {v, i} : r, {v : 0})
    const mode = modeiv.i
    const factor = columns / modeiv.v
    
    for (let i = 0; i < results.length; i++) {
        limit = Math.floor((results[i] || 0) * factor)
        if (!limit) {
            continue
        }
        console.log(`${(' '.repeat(5)+i).slice(-5)}: ${'*'.repeat(limit)}`)
    }
    
    const flatResults = results.flatMap((v, i) => Array(v).fill(i))
    const average = a => a.reduce((r, v) => r + v, 0) / a.length
    const stddev = a => {
        const avg = average(a)
        return Math.sqrt(a.reduce((r, v) => r + (v - avg) * (v - avg), 0) / a.length)
    }
    
    console.log(`Expected Number of Correct Guesses ${(0.5 * rounds).toFixed(3)}`)
    console.log(`Modal Number of Correct Guesses: ${mode}`)
    console.log(`Average Number of Correct Guesses: ${average(flatResults).toFixed(3)}`)
    console.log(`Standard Deviation: ${stddev(flatResults).toFixed(3)}`)
    
    
    VM429:22    16: *
    VM429:22    17: ***
    VM429:22    18: *****
    VM429:22    19: *********
    VM429:22    20: **************
    VM429:22    21: *********************
    VM429:22    22: ****************************
    VM429:22    23: **********************************
    VM429:22    24: **************************************
    VM429:22    25: ****************************************
    VM429:22    26: **************************************
    VM429:22    27: **********************************
    VM429:22    28: ****************************
    VM429:22    29: *********************
    VM429:22    30: ***************
    VM429:22    31: *********
    VM429:22    32: *****
    VM429:22    33: ***
    VM429:22    34: *
    VM429:32 Expected Number of Correct Guesses 25.000
    VM429:33 Modal Number of Correct Guesses: 25
    VM429:34 Average Number of Correct Guesses: 25.000
    VM429:35 Standard Deviation: 3.535
    

    :wtf_owl: You know you can just read the source code to see their "advanced algorithms", right?

    https://web.media.mit.edu/~guysatat/MindReader/MindReaderAlg.js

    But I guess reading it makes you realize they're :trwtf:. (By they I mean MIT media group, since MIT has this curious history of overhyping their toys as something substantial. And people fall for it every single time.)



  • @_P_ said in How random are you?:

    You know you can just read the source code to see their "advanced algorithms", right?

    That would have required effort, also actually visiting the quiz page.

    It was WAY simpler to simulate a Monte Carlo style test assuming both user and bot played as perfectly randomly as Math.Random() could provide.

    Plus this was more about figuring out how to make the histogram output and get the statistics about the various runs.

    I should probably revisit this to see if i can calculate the parameters to the specific binomial distribution in play here... or calculate thinks like the 50% confidence window, the 80% confidence window, stuff like that.

    also I know i can do the stats without needing that intermediate flattened result array. but i gotta think about how to make that work.

    Sure i've got work I should be doing instead, but this is more fun!



  • @Tsaukpaetra Bad news...

    mr2.png

    Edit:
    @Vixen said in How random are you?:

    Self Selection Bias.
    people are a lot less likely to post their losses than their wins.

    Yeah, right before this, I lost something like 25 to 7. I thought if I kept clicking right it'd give up.



  • @Vixen said in How random are you?:

    @_P_ said in How random are you?:

    :trwtf: is every screenshot in this thread shows the bot losing to the user. :trollface:

    Self Selection Bias.

    people are a lot less likely to post their losses than their wins.

    For what it's worth, my narrow victory in the first post was my first try.



  • @Vixen said in How random are you?:

    @_P_ said in How random are you?:

    You know you can just read the source code to see their "advanced algorithms", right?

    That would have required effort, also actually visiting the quiz page.

    It was WAY simpler to simulate a Monte Carlo style test assuming both user and bot played as perfectly randomly as Math.Random() could provide.

    Plus this was more about figuring out how to make the histogram output and get the statistics about the various runs.

    I should probably revisit this to see if i can calculate the parameters to the specific binomial distribution in play here... or calculate thinks like the 50% confidence window, the 80% confidence window, stuff like that.

    also I know i can do the stats without needing that intermediate flattened result array. but i gotta think about how to make that work.

    Sure i've got work I should be doing instead, but this is more fun!

    ...You know you can just interface with the web page UI given you're writing JS and live test their algorithm, right? They even have jQuery imported for you.

    Only writing server-side JS is :trwtf: of :trwtf: there.



  • @_P_ said in How random are you?:

    @Vixen said in How random are you?:

    @_P_ said in How random are you?:

    You know you can just read the source code to see their "advanced algorithms", right?

    That would have required effort, also actually visiting the quiz page.

    It was WAY simpler to simulate a Monte Carlo style test assuming both user and bot played as perfectly randomly as Math.Random() could provide.

    Plus this was more about figuring out how to make the histogram output and get the statistics about the various runs.

    I should probably revisit this to see if i can calculate the parameters to the specific binomial distribution in play here... or calculate thinks like the 50% confidence window, the 80% confidence window, stuff like that.

    also I know i can do the stats without needing that intermediate flattened result array. but i gotta think about how to make that work.

    Sure i've got work I should be doing instead, but this is more fun!

    ...You know you can just interface with the web page UI given you're writing JS and live test their algorithm, right? They even have jQuery imported for you.

    Only writing server-side JS is :trwtf: of :trwtf: there.

    is not server side JS. is COMMAND line JS because there's no http server in use there.

    but yes I could actually test their actual implementation, and may at some point do so.

    because boredom, and also science.



  • @Vixen said in How random are you?:

    @_P_ said in How random are you?:

    @Vixen said in How random are you?:

    @_P_ said in How random are you?:

    You know you can just read the source code to see their "advanced algorithms", right?

    That would have required effort, also actually visiting the quiz page.

    It was WAY simpler to simulate a Monte Carlo style test assuming both user and bot played as perfectly randomly as Math.Random() could provide.

    Plus this was more about figuring out how to make the histogram output and get the statistics about the various runs.

    I should probably revisit this to see if i can calculate the parameters to the specific binomial distribution in play here... or calculate thinks like the 50% confidence window, the 80% confidence window, stuff like that.

    also I know i can do the stats without needing that intermediate flattened result array. but i gotta think about how to make that work.

    Sure i've got work I should be doing instead, but this is more fun!

    ...You know you can just interface with the web page UI given you're writing JS and live test their algorithm, right? They even have jQuery imported for you.

    Only writing server-side JS is :trwtf: of :trwtf: there.

    is not server side JS. is COMMAND line JS because there's no http server in use there.

    but yes I could actually test their actual implementation, and may at some point do so.

    because boredom, and also science.

    I've never seen anyone except the server-side JS hipsters who insist on using use strict and const everywhere. And it's not like that'd actually help them write actually good code, or even better code 🚎



  • @_P_ said in How random are you?:

    insist on using use strict and const everywhere.

    I mean that's just good practice.

    I write use sanity because it's funny and i have eslint set up in strict mode anyway so i can check at "compile" time that i'm safe from what use strict intends to keep me safe from.

    But yeah strict mode and let/const are good things. as are apps hungarian notation where variables are notated based on their semantic kind (I.E. HTML Safe strings being prefixed with ss and non HTML safe strings prefixed with us) as opposed to systems hungarian where variables are notated uselessly with their compiler type (I.E ints prefixed i, longs prefixed iwth l, etc. I know they're ints and longs thanks to intellisense!).

    That just lets you tell me the intent of your declarations. const means you won't change the value, let means it will change value, idxFooBars is an index into a list named FooBars, ssFromUs() is a function for turning an Unsafe String to a Safe String.... Stuff like that is useful to know, even if the compiler/interpreter doesn't need it.

    as for being a hipster..... I mean maybe? imma fox, and i do enjoy wearing a scarf because that makes me look all fancy and more human friendly..... but i don't like coffee and my music tastes are..... rather more eclectic than the hipster stereotype.

    Not vegan. Your chickens are not safe from me. Though I will attempt to ask for permission rather than forgiveness with regards to your hen house.

    And like, sure i'll talk about best coding practices and stuff like that, but if you disagree with me at a fundamental level... Like that's cool. We can disagree and still be fuck buddies friends.

    So..... Yeah.......



  • @Vixen Strict mode (via "use strict") also lets $javascript_engine_of_the_day optimize the compiled representation of your code better. Not as tightly as asm.js, but still better.



  • @TwelveBaud said in How random are you?:

    @Vixen Strict mode (via "use strict") also lets $javascript_engine_of_the_day optimize the compiled representation of your code better. Not as tightly as asm.js, but still better.

    Sure. We do that too.

    node --use_strict app.js

    :-D



  • @TwelveBaud said in How random are you?:

    Strict mode (via "use strict") also lets $javascript_engine_of_the_day optimize the compiled representation of your code better.

    [citation needed]


  • Considered Harmful

    @Vixen said in How random are you?:

    @TwelveBaud said in How random are you?:

    @Vixen Strict mode (via "use strict") also lets $javascript_engine_of_the_day optimize the compiled representation of your code better. Not as tightly as asm.js, but still better.

    Sure. We do that too.

    node --use_strict app.js

    Use the real thing.
    SSFW

    use_strict



  • Not bad, if I do say so myself:

    8a447c96-c7b9-42d3-9670-c4441c86de47-image.png


  • Discourse touched me in a no-no place

    @hungrier said in How random are you?:

    It's like 10000 spoons when all you need is a semicolon Greek question mark at the end of each line of code

    FTFY


  • Discourse touched me in a no-no place

    @GÄ…ska said in How random are you?:

    @Vixen said in How random are you?:

    Liebnitz is still an unassailable target.

    Unspellable too, it seems.

    That is a traditional state of affairs for utterances from well raised lady foxes on this forum.



  • How random am I? You tell me...
    5f62a52d-beee-4e61-985f-83923d203370-image.png



  • bf269062-48ff-4708-8ca4-cb60afd7171d-image.png



  • @_P_ You cheated!



  • @djls45 said in How random are you?:

    @_P_ You cheated!

    That's what they got for not running the game server-side 🚎


  • Considered Harmful

    @dkf said in How random are you?:

    @hungrier said in How random are you?:

    It's like 10000 spoons when all you need is a semicolon Greek question mark at the end of each line of code

    FTFY

    Is that what the old ones called it in APL back in the day?


  • Considered Harmful


  • Banned



  • @error_bot xkcd random


Log in to reply