Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't know any math notation, so I'll just write in plain english. Though it isn't too important, I'm working in Javascript. What I want to know is basically this question on stack overflow, though I think it's more appropriate for here, and it isn't getting much love there, anyway, so here goes.

Javascript has a facility for generating pseudorandom numbers between 1 and 0. However, I want to take the numbers that I get out of this and manipulate them in a way that will distort them with a bias toward numbers closer to 0 and against those closer to 1. I thought and thought about this, but I couldn't figure out how to go about doing it, so I asked and someone on stack told me that I could simply take a random number, and square it. This fulfills what I asked for, but I'd also like to know how, partly just to better my own understanding of the concept, to distribute them linearly.

I created a small script to visualize what different distortions look like here. To use it, you just need to open your javascript console in your browser. On Chrome, this can be done by pressing CTRL+Shift+J.

As you can see, raising the random number to a power produces a curve, like so: enter image description here

Again, how do you produce a line?


share|cite|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.