I have this (pseudocode):
var a = Math.random(); // returns random number from 0 to 1

I would like to have greater probability of selecting lower numbers just like picture describes. How should equation (code) look like?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easiest here is to proceed with Rejection sampling.
Basically you simulate a bi-dimensional variable (x,y) = (Math.random(), Math.random()). It is a point in the square [0,1][0,1]. If the variable (x,y) is in the triangle you drawn, then take x.
x will have the distribution you are looking for.
Pseudocode:
You could actually get away with it by drawing only one random variable (by computing and inverting the Cumulative Distribution Function), but that’s much more complicated in this case.