Random Numbers (How Software Works)

Поділитися
Вставка
  • Опубліковано 22 гру 2024

КОМЕНТАРІ • 174

  • @PizzaLovingNerd
    @PizzaLovingNerd 5 років тому +251

    I knew it would be impossible just by the very nature of computers, so I always wondered how it works... Thanks for explaining it...

    • @jeremiahnoar7504
      @jeremiahnoar7504 5 років тому +5

      on regular computer's it would be impossible. But for a quantum computer, it would be a piece of cake

    • @Manic97LP
      @Manic97LP 5 років тому +4

      @@jeremiahnoar7504 Also possible on a regular Computer, if you plug in a Hardware-RNG or use a CPU with an on-board hardware random number generator.

    • @jacobstewart6014
      @jacobstewart6014 4 роки тому

      Hey its random to see u here lol. I'm Jacob, one of Dylans friends

    • @PizzaLovingNerd
      @PizzaLovingNerd 4 роки тому

      @@jacobstewart6014 Nice

    • @seaparty1236
      @seaparty1236 2 роки тому

      @@Manic97LP never truly random

  • @natgazer
    @natgazer 5 років тому +44

    Pretty interesting. Good animations!
    Random function in programing languages was always something
    that intrigued me

  • @subliminalcastillo2126
    @subliminalcastillo2126 4 роки тому +10

    Thank you! I never put much thought into randomness in software until I started programming, and you gave me exactly the answer that I was looking for. You got yourself a like & a new subscriber.

  • @GurlNamedBrettMarie
    @GurlNamedBrettMarie 4 роки тому +5

    Is it always multiplied by 8 and divided by 11? Or does that change?

  • @amans6504
    @amans6504 3 роки тому +2

    Great explanation. At first sight, i thought computer needs a starting reference to generate some random number, so they must used something like, declaring a variable and accessing its random, which is supposed to be random and then taking the last digit as the random reference. Seems like the seed thing is kind of similar.
    I'd check out your book sure

  • @kaasterly
    @kaasterly 3 роки тому +1

    Excellent video; answers well a question I've had floating in my mind for years!

  • @ketanbhailikar5888
    @ketanbhailikar5888 4 роки тому +18

    6:07 Universe.exe has stopped working.

  • @keksigerkeks3276
    @keksigerkeks3276 2 роки тому

    4:02 About the couple of problems: One of them is, that this line is going to repeat itself as soon as one of the numbers appears as seed a second time. Or did I get it wrong?

  • @ProSpase
    @ProSpase 3 роки тому +1

    Just a random (🤣) thought, which method does Excel’s Rand() function use?

  • @DanteAnzevino
    @DanteAnzevino 4 роки тому +2

    So how do the numbers 8 and 11 change if your have a different rang of numbers? How do you know which two numbers to use?

  • @theionking4773
    @theionking4773 3 роки тому +2

    1:53

  • @amaansiddiqui2376
    @amaansiddiqui2376 2 роки тому +1

    Such a neat video ! Answered the exact question I had in my mind!

  • @TriLool78
    @TriLool78 6 років тому +23

    thank you for making this video i've been looking for an answer for quite a longtime now but everywhere i looked there was only sowtware tutorials.
    as i thought computers can only emulate random.

  • @thorandlundeve
    @thorandlundeve 6 років тому +37

    4:36 straight answer. you're welcome

  • @FunTech009
    @FunTech009 3 роки тому +1

    3:15 how they produce no. 7 ?

  • @fabriperoconalgomasytodojunto
    @fabriperoconalgomasytodojunto 3 роки тому +1

    Men you are a genius! Such a great video. Perfectly explained so that everyone can understand it

  • @jasondeng7677
    @jasondeng7677 5 років тому +3

    4:44
    the wither is easier to kill at 5:23 PM than any other time
    jk
    but there probable exists some time frame where you could predict the wither's movements

    • @laurenzv5682
      @laurenzv5682 4 роки тому

      Yeah but probably you'd have to know the time in ms, and since there's always some sort of delay (slowness of the computer) which is influenced by for example temperature--> influenced by atoms and energy etc and because of the Heisenberg principle it is random

    • @jasondeng7677
      @jasondeng7677 4 роки тому

      @@laurenzv5682
      true, very true.
      and you would need to know the state of the variables first, which would involve seeing the code

    • @gavintantleff
      @gavintantleff 4 роки тому +1

      I can actually say that this is not true (at least in java edition, I don’t know much about C++), or at least a little more complicated than the time you spawn it. Java has a class called Random which can give you random numbers. To create a random, you can input a seed, or leave it empty and it will create a random seed probably using something like system time. In Minecraft, most randoms use the same seed, which is the seed of the world. This is why every world with the same seed randomly generates the same way.
      I haven’t looked much into Minecraft’s code or MCP, but I will say that it’s probably about when you make the world, not when you spawn the wither.

  • @sparklinglatte1
    @sparklinglatte1 2 роки тому +1

    great to know that there is no little gnome throw the dice in my pc btw what is the game name at 1:14

    • @vantonspraul
      @vantonspraul  2 роки тому

      That is The Secret World, a horror MMO that I was really into at the time. It has since been reborn as the free-to-play Secret World Legends. I don't like the progression system in the new version as much, but honestly the storytelling is the reason to play it anyway.

    • @sparklinglatte1
      @sparklinglatte1 2 роки тому

      @@vantonspraul haiya thanks for answer

  • @onlyme0349
    @onlyme0349 6 років тому +5

    This was really well explained thanks!
    I still have questions about which processors have the lamp example and how to generate some random numbers that way

    • @vantonspraul
      @vantonspraul  6 років тому +2

      It's an analogy to circuitry inside Intel processors since Ivy Bridge, accessed via a new RdRand instruction (en.wikipedia.org/wiki/RdRand).

  • @poorman-trending
    @poorman-trending 3 роки тому

    What Is the name of the random generator circuit you talk about at the end?

  • @iparadoxg
    @iparadoxg 4 роки тому +1

    does a modulo of 11 is always used?

  • @gamolly
    @gamolly 4 роки тому

    So, the lamp turning on and off will eventually stabilize and stop being random, right? So, to capture the truly random part we just take the input from the initial "frantic" behaviour of the lamps?

  • @joshingaboutwithjosh
    @joshingaboutwithjosh 2 роки тому

    This helps a tonne thankyou V. Anton

  • @rolandfuhrmann2506
    @rolandfuhrmann2506 6 років тому +4

    Very well explained! I hope I can apply some of that knowledge in my future projects!

  • @FeelingShred
    @FeelingShred 2 роки тому

    Company: "Play our new exciting adventure where you can control a party of 6 characters across dungeons, mountains, kill dragons and marry the hot lady in the end"
    Me playing it: "My entire party is missing attacks on this Rat"

  • @rckli
    @rckli 4 роки тому

    Can you make another going into full detail the part about how a computer itself makes a truly random number?
    Does it use a literal light source with sensors or is it just 2 signals repeating till one maintains?

  • @GenerallyGoodMusic
    @GenerallyGoodMusic 2 роки тому

    Really well explained, thank you!

  • @The_Pariah
    @The_Pariah 2 роки тому

    Viewed 3 videos on RNG.
    This is the ONLY one that was worth the watch.

  • @barneystinson3358
    @barneystinson3358 4 роки тому +1

    So you use lamps to create random numbers?

  • @jamesr4181
    @jamesr4181 4 роки тому +3

    5 x 8 = 40.
    40 divided by 11 = 3.6363636
    So where did the 7 come from?

    • @vantonspraul
      @vantonspraul  4 роки тому +1

      It's not the quotient, it's the modulo -- the remainder. 11 goes into 40 3 times, with a remainder of 7.

    • @jamesr4181
      @jamesr4181 4 роки тому

      @@vantonspraul oh. Thank you. Now I understand.

    • @maheshkshirsagar8432
      @maheshkshirsagar8432 4 роки тому

      Mathematical explanation plz...how 5×8 ÷11 =7?????

    • @maheshkshirsagar8432
      @maheshkshirsagar8432 4 роки тому

      What i do for 0 to 9 random number

    • @vantonspraul
      @vantonspraul  4 роки тому +1

      @@maheshkshirsagar8432 It's not division, it's the remainder of division. So not 40 divided by 11, but the remainder. So 40 divided by 11 is 3. But 3 times 11 is 33, so the remainder is 40 - 33, or 7.

  • @Sameer.Trivedi
    @Sameer.Trivedi 2 роки тому

    Excellent explanation!

  • @MrShadyabs
    @MrShadyabs 4 роки тому

    Very good and Informative ! Is Noise another way to generate the seed for Pseudorandom ? or Is noise used only for True Random generator ? Hope you can help with this
    Thank you :)

  • @jus1t-gg
    @jus1t-gg 3 роки тому

    Very good explanation, I enjoyed it a lot too.

  • @henrykyriacou2262
    @henrykyriacou2262 4 роки тому

    your maths degreee and knowledge is fine and all that, but how does it stop souble skulls in a reroll?

  • @safwan6363
    @safwan6363 3 роки тому

    That’s a good easy to understand explanation, thanks

  • @andylouwrink4672
    @andylouwrink4672 4 роки тому +1

    Damn, 4 years ago and still relevant. By far the best explanation I've seen. Thanks!

  • @shadaxgaming
    @shadaxgaming 5 років тому

    This is a great video, however the issue I'm having with the lamp analogy is that you mention the lamps are initially turned on at *exactly* the same time, but the signals would arrive to each other at only *nearly* the same time. What is happening in a circuit that they don't arrive at *exactly* the same time and how does that change with each trial? What are the random variances, i.e. "chaos theory?"

  • @selinsaki6217
    @selinsaki6217 3 роки тому

    You saved my simulation class, you rock!

  • @tushihahahi
    @tushihahahi 3 роки тому

    This question was asked to me in an interview.
    Generate Random number without using random module in Python?
    Now I know the answer.

  • @franciscogaxiola9450
    @franciscogaxiola9450 8 років тому

    I was curious about the real random numbers, simple way to explain and understand the concept. Good teaching skills.

  • @MTWas
    @MTWas 3 роки тому

    Good explained! Thank you.

  • @veghbela
    @veghbela 5 років тому +1

    I remember using winamp around 2000 the random play option always played the same songs like forever. If I had a playlist of 100 songs, it was only playing about 20 of them, I hated that and thought it can not be random, but I could not know why.
    Did anyone experienced this thing?

    • @FeelingShred
      @FeelingShred 2 роки тому +1

      EXACTLY... most media players I used had that problem, surprisingly... in the case of Winamp at least I could set keyboard hotkeys like Ctrl+Alt+R to toggle Shuffle On and Off, so if I toggled it off, skipped a track, and turned it back on, the Random Number queue would reset for a while

    • @FeelingShred
      @FeelingShred 2 роки тому

      Winamp best player, still using it in Windows 10
      🙏🙏

  • @harryfelix7236
    @harryfelix7236 4 роки тому +1

    Can rng be controlled by developers?

    • @pixelhunter5709
      @pixelhunter5709 3 роки тому

      yes, they can reprogram rng or change it somehow so rng works in same but different way

  • @pzdf8v
    @pzdf8v 2 роки тому

    Python 3.6 released the "secrets" module. It's a secure non-deterministic RNG that is real easy to use. It's just a easy as the "random" module.

    • @vantonspraul
      @vantonspraul  2 роки тому +1

      AFAIK, the secrets module repackages calls to something like os.urandom, which itself is a repackaged call to the underlying operating system to get the random number. So if the OS and hardware supports non-deterministic random numbers, that's what you will get, and if not, you will get a (hopefully well-implemented) software-regenerated pseudorandom number. Point is, the secrets module is not producing the random number itself, and it didn't any new functionality, it just made the ability to call the OS for random numbers more visible, to get programmers to use that feature when strong RNG was needed. You probably already know all this, and I am probably going on too long, I just didn't want someone to read your comment and think that Python had created a non-deterministic RNG in software.

  • @mannaiyanrajesh
    @mannaiyanrajesh 5 років тому +2

    How to workimg random number in lottery

  • @DukagjinMurtezani
    @DukagjinMurtezani 8 років тому +1

    what about pokersites, they also use random cards(numbers), is there any explaination?

    • @vantonspraul
      @vantonspraul  8 років тому +1

      That's a great question. I don't know about poker sites specifically, but I do know that electronic casino gaming machines, such as slot machines and video poker, have to deal with random number generation. Also, the mechanical shufflers that casinos use employ random numbers--instead of just haphazardly mixing cards, the way a human shuffler would, shuffling machines effectively assign a random number to each card position in the deck then sort the cards based on those numbers. I understand that early shufflers and some early electronic casino games used the kind of algorithm I show here for random numbers, and were therefore potentially vulnerable to prediction (although I don't know if this was even profitably exploited). Now I expect they use hardware-generated random numbers but I don't know for sure.

  • @calebmasaba5815
    @calebmasaba5815 6 років тому

    Is it possible to generate a seed from a series of random numbers,like in the lotteries

    • @cityfashion6501
      @cityfashion6501 5 років тому

      I am also looking for it, if u know please let me know

  • @briyandingha3183
    @briyandingha3183 3 роки тому

    I really wish to know how a random number comes twice or thrice in a role

  • @GuyNCorner
    @GuyNCorner 6 років тому

    Im not even an programmer or engineer and that made sense to me. Strong explanation
    (edi) or I hope I understood...

    • @vantonspraul
      @vantonspraul  6 років тому

      Glad you liked it! It was meant to be understandable to non-programmers, so I'm glad to hear I got that right.

  • @fyphfoko
    @fyphfoko 4 роки тому

    i don't dig the lamp scenario
    so, you turn the right lamp on, it tells the left lamp to turn off, which it does. then what? there'd be no point in the left radio sending another signal to the right lamps to say "i'm off, so you need to switch on", then the right radio saying "i am on, so you need to switch off" and so on, so they would probably just leave it there
    so if the lamps were in a normal position, left light on right lamp of and you pulled both chords at once, then what would surely happen is that the left lamp would switch off and the right would switch on, for about a second before returning to their original state, and that would be that
    and if the lamps were both somehow off, then the same thing would happen, the lights would come on, both send a signal and turn each other back off, then as far as the radios are concerned their jobs done so the lamps would remain off

  • @abdullaharshad185
    @abdullaharshad185 3 роки тому

    yes yes yes here I have got the answer of my question. I want to make a software to get the predicted number by using previous draw result. please if you have more videos for predictable number generating software or any other tools to get help then please repply. thank you again

  • @ghb323
    @ghb323 6 років тому +1

    2:52, uh, in the range from 1-10, uh, modulo result can output 0. So its actually 0-10.

    • @vantonspraul
      @vantonspraul  6 років тому +5

      No, as shown, the sequence produces only numbers in the range 0-10. Of course, if 8 times the seed (previous number in sequence) ever produced a multiple of 11, then modulo 11 would result in a 0. But we choose a multiplier and initial seed to avoid that, because if we ever get a 0 in the sequence, we'll just keep generating 0s thereafter.

    • @ghb323
      @ghb323 6 років тому

      V. Anton Spraul oh, oops. Should’ve double check that. Sorry.

  • @randomuser1249
    @randomuser1249 3 роки тому

    Just started doing unity and I though it would be impossible without random.range or something similar.

  • @mattkaczmarczyk6953
    @mattkaczmarczyk6953 6 років тому

    the analogy to game play was very helpful

  • @noah-sj1sg
    @noah-sj1sg 3 роки тому

    nice video thanks

  • @trusharpatel337
    @trusharpatel337 3 роки тому

    Riemann hypothesis.
    Just search it. If you solve you can predict next otp.

  • @sammypoulsom
    @sammypoulsom 4 роки тому +1

    That was SO well explained! thank you so much and keep it up

  • @bushrainayat3443
    @bushrainayat3443 5 років тому

    Thanks. Now I understood how random numbers generates.

  • @simandi1511
    @simandi1511 5 років тому +1

    Im a jurassic park fan, and i did not expect that reference, well done you surprised me!

  • @shadaxgaming
    @shadaxgaming 5 років тому

    What game is that at 1:12?

    • @richrdb
      @richrdb 5 років тому

      World of Tanks

  • @TheSkyGamez
    @TheSkyGamez 6 років тому

    now the only question i have is, where does minecraft get its seed from

  • @amanmaghan9146
    @amanmaghan9146 6 років тому +2

    The lamp example had me thinking about the racing condition in the J-K flip flop.

    • @vantonspraul
      @vantonspraul  6 років тому +1

      That's spot on. The real-world device that example is based up is basically two flip-flops in a cycle.

  • @terabyte4175
    @terabyte4175 5 років тому

    one of the unique videos i have seen about computation theories and how things work... thanks for that knowledge..... keep it up :)

  • @thelordrvm
    @thelordrvm 4 роки тому +1

    Amazing video! I always wondered how does the random function of a calculator works

  • @paullisok6237
    @paullisok6237 3 роки тому

    thanks

  • @GurlNamedBrettMarie
    @GurlNamedBrettMarie 4 роки тому

    What if the numbers are not 1 through 10, but 1 through 15?

  • @Max-cs1dn
    @Max-cs1dn 6 років тому

    What if I need a random number from the range of 1 to 7? How many trials do I need to make them equally likely?

  • @НиколаПоюков
    @НиколаПоюков 3 роки тому

    I might get called stupid for this but i really struggle to see how anything could ever be random? A coin flip’s outcome is determined by the force applied, the movements of the atmosphere around the coin, the distance and surface of the plain its falling to so the outcome can be determined with enough information. I feel this applies for absolutely everything. With enough information of the trillions of factors involved you can predict almost any outcome. This means that everything in the universe is predetermined but seems random just because of the amount of complexity and the variarity and number of factors involved. Can someone see problems in this theory because ive been struggling to prove my self either wrong or right for a while now

    • @vantonspraul
      @vantonspraul  3 роки тому +1

      You are getting into some high-order philosophical questions with this. Indeed, some people don't believe in human free will because of this argument (although, if you are convinced to have an opinion by an argument, that would imply you have free will to choose or reject it).
      In any case, you could be right that even truly random numbers are not random if we mean happening by chance. But if we mean unpredictable, then yes, some numbers are truly random, because there seems to be no way to predict them the way we can with pseudorandom numbers. It might look like there's at least a theoretical way to determine the states of all the variables, but there probably is not, because of the uncertainty principle.

    • @НиколаПоюков
      @НиколаПоюков 3 роки тому

      @@vantonspraul but are my thoughts not predetermined by a multitude of factors? Like the sum of my life experiences and so on? It seems to me that each of my decisions in life could have been predetermined? (only theoretically because no man could have the amount of information required) it seems to me that a hypothetical super computer that knows absolutely everything and can calculate that incoming information could also determine everything that is to happen. The way you mentioned in the video to make true random numbers still seems only pseudorandom to be because the speed of those radio waves would be determined by the atmosphere and other outside factors and if you could know all of their effects you could predetermine the supposedly random number that is to be generated. At least this is what seems to make the most sense to me but i seek a higher understanding that is why i made the comment, to see other peoples opinions and hopefully have a discussion

    •  2 роки тому

      @@НиколаПоюков You'd enjoy watching Veritasium's video "What is not random?", and Vsauce's video "What is random?"

    • @НиколаПоюков
      @НиколаПоюков 2 роки тому

      @ that is a very good recommendation, i have watched both before coming up with my question but none the less both videos are extremely informative and entertaining

  • @MariusOberholster
    @MariusOberholster 2 роки тому

    Fascinating!! :D

  • @quagengineer1877
    @quagengineer1877 4 роки тому

    How we stabilish a range with pseudorandom?

    • @eNtrozx
      @eNtrozx 4 роки тому

      the modulo

  • @Bangy
    @Bangy 4 роки тому +2

    Maybe an API that queries a Lava Lamp Farm would make it more random.

  • @gabrielr.7423
    @gabrielr.7423 9 років тому +2

    Success in your new publication.
    Gabriel R. here!

    • @vantonspraul
      @vantonspraul  9 років тому

      ***** Thanks, Gabriel! Hope you are doing well.

  • @PranitKothari
    @PranitKothari 9 років тому +1

    Wow! really great lesson. Eagerly waiting for your book to come out.

    • @vantonspraul
      @vantonspraul  9 років тому

      ***** Thanks! I should have a couple more videos up by the time is book is out.

  • @kingKabali
    @kingKabali 4 роки тому

    'How random random numbers actually are.'
    'Well that part is little complicated. '

  • @ImTabe
    @ImTabe 5 років тому

    Really helpful.

  • @rohitrawat9765
    @rohitrawat9765 9 років тому

    Awesome Lessson!! Kindly make a video on "Design Patterns for a layman".

    • @vantonspraul
      @vantonspraul  9 років тому

      rohit rawat Thanks for the suggestion. That's a "Think Like a Programmer" topic...design patterns are covered some in the TLAP book, but let me see if I can develop a good video on what you're suggesting, an intro to the concept.

  • @MW3inat0r
    @MW3inat0r 9 років тому +1

    Nice Video!

  • @xslite300
    @xslite300 6 років тому +3

    exactly what i was looking for !

  • @davidjohnston4240
    @davidjohnston4240 2 роки тому

    This is plain wrong. Software can produce nondeterministic random numbers when the instruction set of the computer has nondeterministic instructions. Every current X86 CPU includes two nondeterministic instructions - RdRand and RdSeed. Software is just an assemblage of CPU instruction and if some the the instructions are nondeterministic then so can the software be nondeterministic.

    • @vantonspraul
      @vantonspraul  2 роки тому

      What exactly is "plain wrong"? I don't mean to be snarky, but: did you watch the entire video before posting this comment? Starting around 5:20 I talk about how some processors have instructions to produce truly random numbers for use by software; this was still a fairly new feature at the time when I made the video.

    • @DavidJohnston_deadhat
      @DavidJohnston_deadhat 2 роки тому

      @@vantonspraul I mean it is plain wrong to say software cannot be nondeterministic. Obviously it can be if the underlying instructions include nondeterminstic instructions. Your explanations of the relationship between deterministic software and hardware that grants it access to nondeterministic data is correct, but the characterization of software being always deterministic is not right.

  • @ElifArslan-l9g
    @ElifArslan-l9g 4 роки тому

    thank youu

  • @patrickmutuku9579
    @patrickmutuku9579 8 років тому

    So helpful.... Thanks!

    • @vantonspraul
      @vantonspraul  8 років тому

      You're welcome! Glad you liked it.

  • @tweaker1968
    @tweaker1968 5 років тому

    Thanks for the video... always wondered about this....

  • @fatihsevinc8626
    @fatihsevinc8626 6 років тому

    Very well explained, thanks.

  • @odthegreatest
    @odthegreatest 5 років тому +4

    @2:22 I knew it

  • @giorgi_122
    @giorgi_122 3 роки тому

    I was watching this at 7:33 PM when i was at 4:43. Am i in a Matrix? what a coincidence

  • @mahtidhussen921
    @mahtidhussen921 7 років тому

    i can not understand your lamp example

    • @aaron6807
      @aaron6807 6 років тому

      learn about the chaos theory

    • @4pxris3
      @4pxris3 6 років тому

      simple:
      if one lamp is turned on, the other is off
      if you click both buttons from both lamps at the same time, it is random which one gets turned on and which one gets turnes off

  • @k_andr3
    @k_andr3 5 років тому

    Great video, thank you

  • @lilhuddy1254
    @lilhuddy1254 6 років тому +9

    I’m watching this because I have shitty RNG

    • @gavintantleff
      @gavintantleff 4 роки тому

      Jelwi HAF he’s making a joke about video games

  • @dayman161172
    @dayman161172 3 роки тому

    If we can prove that true random numbers are deterministic and are bound by a physical law we can predict the outcome. Which would proves that we have no free will

  • @meesvandenberg9468
    @meesvandenberg9468 3 роки тому

    Why was that sofa there

  • @marcoseliasmep
    @marcoseliasmep 5 років тому

    Amazing!

  • @stage666
    @stage666 7 років тому

    very well explained. Subbed!

  • @dehrk9024
    @dehrk9024 5 років тому +1

    Am i a nerd if i tought about how a pc could generate something random and then google it? 😂

  • @jeppetofft
    @jeppetofft 5 років тому

    Thanks! That actually make sense.

  • @SalmanYU
    @SalmanYU 4 роки тому

    i was sitting in class one day thinking how in the world does a computer generate a random number, there's no way that's possible

  • @georgesamaras2922
    @georgesamaras2922 3 роки тому

    No starch books are the best

  • @flamepotatoes
    @flamepotatoes 4 роки тому

    Now I have anxiety about the number I generate.

  • @vitopos8153
    @vitopos8153 4 роки тому

    Actually there is no such thing as true random. Thanks for the video! Very cool

  • @milenkirov1340
    @milenkirov1340 4 роки тому

    1599

  • @dailycoderweeklyhooper
    @dailycoderweeklyhooper 4 роки тому

    I guess for the true random one, it will eventually become transistors