Live data from Hacker News

Kid Pix as a JavaScript App

kidpix.app

61–70 of 94 posts

Re: Kid Pix as a JavaScript App

#63

Anyone think they can explain this in the source code? function ziggurat() { return ((Math.random() + Math.random() + Math.random() + Math.random() + Math.random() + Math.random()) - 3) / 3; } https://github.com/vikrum/kidpix/blob/9385acf5b3f57cdc8c5b3f...

Looks like a way to purposefully create a biased (center-weighted) random number generator out of multiple calls.

Re: Kid Pix as a JavaScript App

#64

Anyone think they can explain this in the source code? function ziggurat() { return ((Math.random() + Math.random() + Math.random() + Math.random() + Math.random() + Math.random()) - 3) / 3; } https://github.com/vikrum/kidpix/blob/9385acf5b3f57cdc8c5b3f...

Looks like a way to purposefully create a biased (center-weighted) random number generator out of multiple calls.

Mathematically is the sum of six Math.random() any different than (Math.random() * 6)?

Re: Kid Pix as a JavaScript App

#65

I like it. I think it's missing the option to increase the stamp sizes though? What I really liked about Kid Pix was the ability to make animations through the slideshow mode. You could put together up to 100 pictures in a slideshow and set the time per slide to < 1 second to create animations.

> I think it's missing the option to increase the stamp sizes though?

Holding Shift doubles the stamp size. I think this is accurate to the original implementation.

> What I really liked about Kid Pix was the ability to make animations through the slideshow mode.

That must have been in a later version. I don't remember that existing.

Re: Kid Pix as a JavaScript App

#66

Earlier quoted context omitted.

Looks like a way to purposefully create a biased (center-weighted) random number generator out of multiple calls.

Mathematically is the sum of six Math.random() any different than (Math.random() * 6)?

Yeah, it will biased towards the center of the range rather than uniformly distributed

Re: Kid Pix as a JavaScript App

#67

Earlier quoted context omitted.

Looks like a way to purposefully create a biased (center-weighted) random number generator out of multiple calls.

Mathematically is the sum of six Math.random() any different than (Math.random() * 6)?

Yep, the sum of six Math.random() will start to look a bit like a normal distribution, while Math.random()*6 will stay flat.

Even crazier: the sum of six (Math.random()>.5)?0:1 will also look a bit like a normal distribution, rather than just 0 50% of the time and 6 50% of the time.

Central Limit Theorem eats distributions of all shapes and sizes and shits gaussians. That's why you see normal distributions everywhere.

Post reply on HN