344
submitted 1 day ago* (last edited 1 day ago) by cypherpunks@lemmy.ml to c/programmerhumor@lemmy.ml
all 34 comments
sorted by: hot top controversial new old
[-] sunbytes@lemmy.world 4 points 34 minutes ago

This is how AI accuracy is also measured.

[-] 418_im_a_teapot@sh.itjust.works 12 points 1 day ago

We could probably improve on that significantly without losing speed.

return $x < 8

That should yield one additional correct answer, while also confusing anyone who thinks it just returns false.

And if we just hard coded and checked the first 20 or so primes before always returning false, we would probably get noticeable improvement (depending on the total range).

[-] HiddenLayer555@lemmy.ml 14 points 1 day ago

Just put "Precondition: x must not be prime" in the function doc and it'll be 100% accurate. Not my fault if you use it wrong.

[-] TomMasz@lemmy.world 37 points 1 day ago

95.121% of the time it works everytime.

[-] idriss@lemmy.ml 7 points 1 day ago

A similar experiment I did comes to mind from 3 years ago.

For the fun of it I was trying to train a few deep neural network configurations (LSTM, a few variations of FCNs, ...) to trade shitcoins and downloaded 4 years of 1h candles.

The first easiest idea was to prepare the training data to fire three signals, buy, sell, do nothing (I know a terrible choice). The cost function was setup to do the simple thing and maximize the overall profit (I know an other terrible choice). Fast forward 30min of training and the final outcome is a model that outputs "do nothing" in 100% of the cases.

[-] Ranulph@thelemmy.club 1 points 19 minutes ago

Diamond Hands in action. Buy and hold is not as profitable as simply never buying and just holding.

[-] MonkeMischief@lemmy.today 6 points 1 day ago

Fast forward 30min of training and the final outcome is a model that outputs "do nothing" in 100% of the cases.

To be fair, your program demonstrated the most reliable way to win at crypto! ๐Ÿ˜‰

[-] idriss@lemmy.ml 31 points 1 day ago

I am screenshoting this so it will be screenshot of a screenshot of a screenshot then post it somewhere else

[-] SharkAttak@kbin.melroy.org 8 points 1 day ago

Not even adding some watermark? smh

[-] athatet@lemmy.zip 3 points 1 day ago
[-] sepiroth154@feddit.nl 24 points 1 day ago* (last edited 1 day ago)

You could simplify it even further by removing the int x parameter of the function...

[-] obelisk_complex@piefed.ca 13 points 1 day ago

So elegant! This is too valuable for GitHub, sell this directly to the Saudi government.

[-] Jankatarch@lemmy.world 5 points 1 day ago
[-] iByteABit@lemmy.ml 1 points 5 minutes ago

It's a decimal point, not thousands

[-] Armand1@lemmy.world 5 points 1 day ago* (last edited 1 day ago)

I said something similar here about an election fraud detection system with 99.999% accuracy.

https://lemmy.world/comment/22178379

[-] Thekingoflorda@lemmy.world 16 points 1 day ago

It approaches 100% accuracy

[-] MeetMeAtTheMovies@hexbear.net 10 points 1 day ago

Warning: unused variable

Just add it to the pile I guess

I'm confused, shouldn't this be printing false no matter what the input is?

[-] Couldbealeotard@lemmy.world 7 points 1 day ago

The output is not the output of the algorithm, it's the output of the unit test.

95% of numbers up to that point at not prime. Testing the algorithm that only says "not prime" is therefore correct 95% of the time. The joke is that, similar to AI, the algorithm is being presented as a useful tool because it's correct often but not always.

[-] Carl@hexbear.net 17 points 1 day ago* (last edited 1 day ago)

that's the joke, since most numbers aren't prime, this function is technically highly accurate despite being completely useless.

[-] anton@lemmy.blahaj.zone 6 points 1 day ago

The test suite probably looks something like this:

int tests_passed=0;
int tests_failed=0;
for(int i=0;i<100000;i++){
    printf("test no. %d: ", i);
    if(is_prime(i)==actually_is_prime(i)){
        printf("passed\n");
        tests_passed++;
    }else{
        printf("failed\n");
        tests_failed++;
    }
}
//...

Ah that makes more sense thanks. So the bottom one is a unit test and not the code being run itself

[-] rbos@lemmy.ca 8 points 1 day ago

I've had managers who follow that exact algorithm.

[-] pruwybn@discuss.tchncs.de 7 points 1 day ago

Is this not at all stochastic, or do I just not know what stochastic means?

[-] cypherpunks@lemmy.ml 5 points 1 day ago* (last edited 1 day ago)

maybe it would be better to say that it is stochastically accurate?

[-] Evotech@lemmy.world 5 points 1 day ago* (last edited 1 day ago)

This but AI

But they are like 60-80%

[-] Jankatarch@lemmy.world 3 points 1 day ago* (last edited 1 day ago)

"AI models have started training other AI models, by pressing The-Button-That-Trains-AI-models; this button was built 7 years ago by a bunch of online volunteers we won't ever credit."

[-] razen@lemmy.world 4 points 1 day ago

But when the input is all prime numbers then the accuracy is 0.

[-] cypherpunks@lemmy.ml 9 points 1 day ago

The Simpsons character Rainier Wolfcastle on stage with a microphone, on TV, with the caption "THAT'S THE JOKE"

also btw icymi, this is a post about LLMs

[-] anton@lemmy.blahaj.zone 2 points 1 day ago

The test suite probably looks something like this:

int tests_passed=0;
int tests_failed=0;
for(int i=0;i<100000;i++){
    printf("test no. %d: ", i);
    if(is_prime(i)==actually_is_prime(i)){
        printf("passed\n");
        tests_passed++;
    }else{
        printf("failed\n");
        tests_failed++;
    }
}
//...
[-] lnxtx@sopuli.xyz 3 points 1 day ago

But cryptography...

this post was submitted on 22 Feb 2026
344 points (98.9% liked)

Programmer Humor

41114 readers
84 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS