7 ms·
What language? What are the parameters for the random function here (seed? upper range value in a uniform distribution? stddev for a random distribution?) Why?
by tbalsam 3y ago
What language? What are the parameters for the random function here (seed? upper range value in a uniform distribution? stddev for a random distribution?) Why? What is this demonstrating?
I can grok a lot of the dimensional effects of randomness but without these things specified, the picture is rather meaningless to me.
- maxbond 3y ago1. The language is Processing 2. The argument is the high end of the range (0 to n [https://processing.org/reference/random_.html https://processing.org/reference/random_.html]) 3. I dunno why, it seems like it's just cool. It seems to demonstrate that random(random(...)) collapses to 0, which is exactly what I expected but it's pretty cool.
- deleted 3y ago[deleted]
- tbalsam 3y agoI'm a little confused then what the value of this demonstration is. The expectation marches by half the distance towards the outer edge each time, so it becomes a soap bubble at a rate of 1/2^n Which is nice and sorta cool but I'm not quite sure what the "whoa" factor here is. It's like one of those zip cinch tops for those bags. Sorta cool how it works on observation, really cool in detail, but also sorta...meh? At the same time? Maybe I'm a bit jaded here? Admittedly, a continuous animation of this would be an improvement on the cool factor to me, personally.
- deleted 3y ago[deleted]
- maxbond 3y agoWell, all I can tell you is that I'm having a good time discussing the nitty gritty of it in the comments here, and it made the gears of my mind turn in a pleasant way. It didn't make me go, "wow," but it did make me go, "hmm...."
- tbalsam 3y agoGotcha, yeah, that makes sense to me now. Maybe the real article was the HN comments section that we made along the way....
- walterbell 3y ago> Maybe the real article was the HN comments section that we made along the way.... Nominating this comment for https://news.ycombinator.com/highlights https://news.ycombinator.com/highlights
- deleted 3y ago[deleted]
- tomjakubowski 3y ago"Misunderstanding is the foundation of human discourse."—Jacques Lacan
- antonvs 3y agoIt’s a kind of stone soup situation. With the OP providing the stone.
- deleted 3y ago[deleted]
- sobellian 3y agoI think the sequence tends toward the edge at exp(-n), not 2^-n. The distance from the edge is a product of n I.I.D. variables, so the logarithm is a sum of n I.I.D. variables, and the central limit theorem gives us the result. You can confirm in a python terminal (or anything else) that the product of n `random()`s decreases more rapidly than 2^-n. So maybe there's some value in it after all :)
- tbalsam 3y agoHow do you mean? I'm going based on the propagation of expectations through the system. The expectation of a uniform distribution is half the bound. Unless there's some math shenanigans going on, I believe that the expected expected value of a distribution drawn from distributions should be 1/2 * 1/2 * 1 in this case. Of course it's not a bound but right now I'm having a hard time determining otherwise. Is there a mathematical motivation for e^-n here? That seems an odd choice since the uniform distribution is 0-1 bounded generally. However I could understand if it emerges in a few conditions.
- sobellian 3y agoe shows up because we're doing an iterated product (of random variables, but still). If you look at the central limit theorem, sum(log(rand())) tends to N * E[log(rand())] for large N. Well, what's E[log(rand())]? -1! Like I said, it's fairly easy to test this in a python terminal. I encourage anyone who doubts me to try it :)
- tbalsam 3y agoAlright, I tried it in the terminal and the numbers confirmed my earlier math. .5->.25->.125 mean as N->infinity. I chained the python uniform function like the above code in the originally linked post does and averaged the results. The snark to me and the other commenters is a bit unnecessary in either case. I'm not really sure where you're getting a natural log or an iterated product of random variables in this instance. Could you perhaps show where you're transforming uniform(uniform(uniform(uniform(0, 1)))) into the math you're showing above? I'm trying to follow along here but am having difficulty connecting your line of reasoning to the problem at hand.
- nimih 3y agoSpeaking personally, a webpage with nothing beyond a cool or interesting sequence of images is already in the 90th percentile of good HN posts.
- justinpombrio 3y agoQ4: What is it plotting? `random()` returns a float, right? Is it plotting... r*cis(theta), where r is the random invocation and theta varies uniformly across the circle, normalized so that all the circles are the same size (where cis(theta) = (cos(theta), sin(theta))?
- maxbond 3y agoNah, it's plotting polar vectors, and it uniformly picks an angle. The random(...) is just the magnitude of the vector.
- justinpombrio 3y agoFYI, r*cis(theta) _is_ a polar vector. So it's the thing I said, but with the angle chosen randomly.
- deleted 3y ago[deleted]
- maxbond 3y agoGotcha. My bad, thanks for clarifying.
- bregma 3y agoSo, what PRNG does Random() use? LCG (linear congruential)? LFS (lagged Fibonacci)? MT (Mersenne twister)? In each case it's a linear function of some global variable, not any kind of random number generator. Treating it as if it's a random number generator is silly. It's a pseudo-random number generator, pure algebra.
- jlhawn 3y agoThis is a drawing app using P5.js Click the "</>" at the top to read the code. There's a popular "Let's Code" YouTube channel called The Coding Train that uses it. It's quite acccessible.
- dist-epoch 3y agoThe documentation suggests random() without arguments is not supported random(high) random(low, high) https://processing.org/reference/random_.html https://processing.org/reference/random_.html
- TaylorAlexander 3y agoOooh it’s a high value, I thought it was a seed and that this was demonstrating a flaw in the algorithm.
- tbalsam 3y agoSame, at first at least.