The Bard's Lemmy
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
not_IO@lemmy.blahaj.zone to Programmer Humor@programming.devEnglish · 9 months ago

o(1) statistical prime approximation

lemmy.blahaj.zone

message-square
17
link
fedilink
569

o(1) statistical prime approximation

lemmy.blahaj.zone

not_IO@lemmy.blahaj.zone to Programmer Humor@programming.devEnglish · 9 months ago
message-square
17
link
fedilink

https://cosocial.ca/@mhoye/116111505546606451

alert-triangle
You must log in or register to comment.
  • apex32@lemmy.world
    link
    fedilink
    arrow-up
    40
    ·
    9 months ago

    Reminds me of this xkcd:

    https://xkcd.com/221/

    • Tekhne@sh.itjust.works
      link
      fedilink
      arrow-up
      37
      ·
      9 months ago

      More like: https://xkcd.com/2236/

      • ulterno@programming.dev
        link
        fedilink
        English
        arrow-up
        8
        ·
        9 months ago

        info

        View the source to see how I embedded the picture without copying it. The hover text had to be copied though.

    • ulterno@programming.dev
      link
      fedilink
      English
      arrow-up
      11
      ·
      9 months ago

      info

      View the source to see how I embedded the picture without copying it. The hover text had to be copied though.

    • brian@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      9 months ago

      also sort of https://xkcd.com/2934/

  • BradleyUffner@lemmy.world
    link
    fedilink
    English
    arrow-up
    27
    arrow-down
    1
    ·
    9 months ago

    My favorite part of this is that they test it up to 99999 and we see that it fails for 99991, so that means somewhere in the test they actually implemented a properly working function.

    • anton@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      7
      ·
      9 months ago

      That’s a legitimate thing to do if you have a slow implementation that’s easy to verify and a fast implementation that isn’t.

  • fckreddit@lemmy.ml
    link
    fedilink
    arrow-up
    26
    arrow-down
    1
    ·
    9 months ago

    LLMs belong to the same category. Seemingly right, but not really right.

    • Viceversa@lemmy.world
      link
      fedilink
      arrow-up
      8
      arrow-down
      1
      ·
      9 months ago

      l/whoosh

  • Boomer Humor Doomergod@lemmy.world
    link
    fedilink
    English
    arrow-up
    11
    arrow-down
    2
    ·
    9 months ago

    If you scaled it based on the size of the integer you could get that up to 99.9% test accuracy. Like if it’s less than 10 give it 50% odds of returning false, if it’s under 50 give it 10% odds, otherwise return false.

    • JackbyDev@programming.dev
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      9 months ago

      Makes me wonder where the actual break even would be. Like how long does making one random number take versus sins lookups. Fuck it, do it in parallel. Fastest wins.

  • JustARegularNerd@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    11
    arrow-down
    5
    ·
    9 months ago

    I’m struggling to follow the code here. I’m guessing it’s C++ (which I’m very unfamiliar with)

    bool is_prime(int x) {
        return false;
    }
    

    Wouldn’t this just always return false regardless of x (which I presume is half the joke)? Why is it that when it’s tested up to 99999, it has a roughly 95% success rate then?

    • kraftpudding@lemmy.world
      link
      fedilink
      arrow-up
      25
      ·
      9 months ago

      I suppose because about 5% of numbers are actually prime numbers, so false is not the output an algorithm checking for prime numbers should return

      • JustARegularNerd@lemmy.dbzer0.com
        link
        fedilink
        arrow-up
        6
        ·
        9 months ago

        Oh I’m with you, the tests are precalculated and expect a true to return on something like 99991, this function as expected returns false, which throws the test into a fail.

        Thank you for that explanation

        • Agent641@lemmy.world
          link
          fedilink
          arrow-up
          3
          ·
          9 months ago

          And the natural distribution of primes gets smaller as integer length increases

    • Hexarei@beehaw.org
      link
      fedilink
      arrow-up
      4
      ·
      9 months ago

      Because only 5% of those numbers are prime

  • red_tomato@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    9 months ago

    It has actually 100% accuracy

Programmer Humor@programming.dev

programmer_humor@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmer_humor@programming.dev

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
    • If the mod doesn’t find it funny, you’re banned. Ha-ha!.. For real: do not use the community for “statements”. There are other places for such content. Keep it chill and funny.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 54 users / day
  • 1.95K users / week
  • 3.88K users / month
  • 8.43K users / 6 months
  • 1 local subscriber
  • 34.3K subscribers
  • 1.86K Posts
  • 32.9K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.21
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org