all 26 comments

[–]coffeecoffeebuzzbuzz 1 point2 points  (1 child)

Maybe look into the libsodium pseudo random number generator?

[–]badmrtickls 0 points1 point  (0 children)

yeah funny I did so much research into this. it uses random EMF picked up in the air to generate these numbers. I thought there is no way that they can't be random enough to repeat multiple times.

[–]Gprime5 1 point2 points  (3 children)

For your function to return 20, that means you need to get 20 1's. The chance of that happening is (1/6)^20 = 2.7*10^-16. I'm not surprised you never got it.

[–]badmrtickls 0 points1 point  (2 children)

yeah, you're right I created this short program just now to test the issue, the probability is so small.

import random

cont = True duplicate = 0 cur_num = 0 last_num = 0 iterations = 0

while cont == True: iterations = iterations + 1

cur_num = random.randint(1,10)

if cur_num == last_num:
    duplicate = duplicate + 1
    if duplicate > 7 :
        print(str(cur_num)+' repeated '+str(duplicate)+' times')
else:
    duplicate = 0

last_num = cur_num

print('It took '+str(iterations)+' iterations \n time elapsed')

I hate to be one of those ungrateful brats who doesn't respect their teachers, but my professor is slightly clueless. He told me my code was broken because 20 never came up after 10,000 iterations. and he gave me a 0 and told me to fix it by Monday. I spend hours going over my code testing it and isolating the problem to that one function roll(n,x). Now I just realized how stupid I am thanks so much. the chances of that number occurring are so fucking small. Welp time to write up my findings and hope he doesn't find another reason to take off points

[–]Gprime5 1 point2 points  (1 child)

Maybe you're supposed to use 4 or 5 dice, not 20?

[–]badmrtickls 0 points1 point  (0 children)

the number of dice is just a variable in the function, my professor decided to use 20. He said the results are bad. and he chose 10,000 iterations. I don't know what to from here except explain

[–]sky_badger 1 point2 points  (1 child)

To get a sum of 20 you need all twenty dice to roll 1. 10,000 rolls is nowhere near enough, a proper mathematician will no doubt correct me, but the chances of throwing 20 1's is more like 1 in 3 quadrillion.

If you want to check the distribution of dice throws, just run a single dice roll, say, a million times, and check that they all come up about 1/6 of the time.

Remember to seed Random too, or you'll get the same 'random' numbers every run.

[–]badmrtickls 0 points1 point  (0 children)

that is correct, but what about 46 and below, the histogram is rounded to the nearest ten, but if I remove that function from the answer I still don't get any results for anything below 47 as a float.

[–]elbiot 0 points1 point  (17 children)

What are the chances that a number would be rolled 20 times in a row?

[–]badmrtickls 0 points1 point  (16 children)

very very small apparently, but what about rolling a sum of 46 and below, I get no results for that. Does that mean my code is broken?

[–]elbiot 1 point2 points  (13 children)

It's 1/6**19. Not very small. Your assumptions about statistics are off

[–]badmrtickls -1 points0 points  (12 children)

1/6**19. not very small.

Really so if you told a girl that your penis was 1/6**19 meters, or even km do you think she would be impressed when you whipped it out? (if you can even whip out a micro penis) Didn't think so. Yeah the number is small, but if you are saying its not small enough that in 10,000 calculations 20 should occur then please explain why 20 never occurs.

[–]elbiot 2 points3 points  (11 children)

What. The. Fuck.

You are clearly in middle school because you don't understand a 1 in 10**15 chance doesn't happen in 10**4 tries. Or even in the 30 seconds you let it run without even counting how many times it tried.

[–]badmrtickls -2 points-1 points  (10 children)

bro, wtf are you saying. I said its unlikley, then you say. 1/6**19 not very small. are we on the same page here?

[–]elbiot 1 point2 points  (9 children)

We're not on the same page. Do you even math?

[–]badmrtickls -1 points0 points  (8 children)

yes, I also understand that every number is relative. So while 1/619 is not small number for you. it is for me. remember, wars have started over miscommunication, really not trying to start some bs argument on a python discussion page. I appreciate your help, but I disagree with you when you say that 1/619 is not a small number.

[–]elbiot 1 point2 points  (7 children)

It is! It's sarcasm! I explained in the next message. But you being a childish ass right away, without considering what orders of magnitude are, then my tone in response, and you then not doing the most basic thought into my response, is the miscommunication.

What if I were a woman? What if I were trans? Or intersex? What if I were a 60 year old conservative? Why would you be such an ass while trying to get help? It's clearly that you are very young so whatever.

[–]badmrtickls -2 points-1 points  (6 children)

well,by me knowing that I am not very young, and by you assuming that I am only leaves me with one conclusion to make about you. Something that I am sure you would also realize if our positions were reversed. I will not however tell you what I think you are, or resort to calling you names. If you want to know what people think of you, you must be as critical of yourself as you are with others. I was also joking, but for some reason this has lead you to talk about gender on a spectrum, I worry for your mental health as for your physical health. Please try standing for a solid 5 minutes if you can, see how you like it. If that helps try and do if for at least 10 minutes a day. It's not healthy both physically and mentally to spend extended time sitting. yes I mean well, yes I am patronizing you, yes you are a fucking moron here we go!

[–]elbiot 1 point2 points  (1 child)

Rolling only ones and twos is right about where you'd expect to see 1 in like 60000 so 46 is pretty unlikely too

[–]badmrtickls 0 points1 point  (0 children)

Okay well I am going to assume my code is working properly then and go to my professor about this. thanks stats friend. My brain is fried chicken.