0
$\begingroup$

Hopefully this isn't a duplicate, I've tried to search for similar things, but to no luck.

I'm curious on how you would computationally compute a random distribution of numbers that follows a bell curve that's got slightly different constraints than normal. For example, a 'regular' bell curve graph ranging from 0-100 would be generated by something like: (rand(100) + rand(100) + rand(100)) / 3

I would like to get some more information on how to 'customize' these graphs.

For example, let's say I want:

  • Set min and max value. For this example, let's say 0-100
  • Set more or less specific requirements. For example, I want the highest distribution to be 10-20, so those being the most common.
  • then a 'normal' curve down to the edges, despite the off-balance. For example, there is the same chance of getting 0 and 100.
  • Another possibility would be having a steeper slope on one side than the other, despite having a regular curve. (Regular distribution being 50, but a much greater chance of getting 0 than 100, for example)

I know I can get a steeper curve by increasing the number of rands that I get the average of. Would 'breaking' the average cause the imbalance I'm looking for there? For example, (rand(100) + rand(100) + rand(100) / 4) would cause a lower regular distribution.

EDIT: To answer the comments below, I'll add to this. I added the 4 constraints in hope that that would make it less broad, but apparently it's still too vague.

As far as example data, I'm looking for something that I can apply in many areas. The current situation I'm trying to apply this in, is generating an example score set for a potentially never ending game.

Picture any infinite progression/distance game. Generally easy to play with simple rules. Easy enough that players will rarely score 0, most players eventually make a mistake and fail early on-ish, and a select few players make it super far. By this, assuming a scale of 0-100, you get something like this:

Distribution | Score
    1%       -   0-3
    3%       -   4-9
   20%       -   10-20
   40%       -   21-40
   20%       -   41-60
   10%       -   61-70
    3%       -   71-80
    2%       -   81-90
    1%       -   91-100

Those are all obviously made-up results, but is shows approximately the goal. It's basically a bell curve, where most values are found in one area and are distributed apart from it, but it's not a regular curve, seeing as the peak isn't centered, and the two slopes don't have the same slopes. Even if it's not exact, that's fine. I'm looking for simple/easy to implement and straight forward, but I'm not looking for the mathematical formula to generate the graph, but rather the algorithm that can be used to approximately generate the numbers, like I showed an example of previously.

I'm not concerned with the actual random value of the numbers, but rather what I need to do, given an assumed random number generation. rand(100) would like to manipulate that into a customizable function that, run many times, the points generated would approximately reflect a the desired curve.

$\endgroup$
6
  • 3
    $\begingroup$ Ultimately, this question asks how one ought to go about choosing probability models. As such, it seems to be far too broad to be answerable. You could narrow it by specifying why you are trying to develop such a distribution and telling us what data or other information are available to help guide you. $\endgroup$
    – whuber
    Commented Jan 26, 2016 at 19:51
  • $\begingroup$ Although I take @whuber's point, and add that "regular" is left vague here, it seems that a beta distribution fulfils the most important requirements here. See e.g. en.wikipedia.org/wiki/Beta_distribution The bounds of 0 and 1 don't bite as you can just apply a linear transformation. Good software includes routines for random draws from a beta. $\endgroup$
    – Nick Cox
    Commented Jan 26, 2016 at 20:06
  • 3
    $\begingroup$ "Any real answers (with actual algorithms), explanations, or good references to articles count. ,,, Please include a basic summary of the article for future reference. " That's a tough stipulation for strangers volunteering their time: sounds like the text that would describe the conditions for a very large bounty. $\endgroup$
    – Nick Cox
    Commented Jan 26, 2016 at 20:08
  • $\begingroup$ Are you simply wanting to customize pictures (graphs) or are you wanting to do something with them? If you want to do something with them, what do you want to do, specifically? $\endgroup$
    – Wayne
    Commented Jan 26, 2016 at 20:33
  • $\begingroup$ @Wayne - I want to further my understanding of how to generate a set of numbers, that, in large numbers, will resemble those graphs. $\endgroup$ Commented Jan 26, 2016 at 21:08

3 Answers 3

1
$\begingroup$

I see two ways to do what you want.

First, you could leave your description of the generation process vague and come up with arbitrary probabilities, as you did in your example above. Then translate your table into, say, R. Let me do something like your example over just five numbers:

nums  <- c(0,    1,   2,   3,   4,   5)
probs <- c(0.01, 0.2, 0.4, 0.2, 0.1, 0.01)

s <- sample (nums, 1000, replace=TRUE, prob=probs)

table (s)
plot (table (s))

This is obviously not the way that folks on a statistics website would advise you to do it. Your table is arbitrary and a matter of your wild guesses about how something might work. You could as easily get a nice drawing program that lets you draw nice curves and just draw it.

Second, you could try to model your generation process. Look at the Wikipedia statistical distribution list and see what distributions match your idea.

For example, the Binomial Distribution reflects "the number of successes in a sequence of n independent yes/no experiments, each of which yields success with probability p." Is that how you envision your game working? So your contestants each take 100 turns, and their score is how many turns in which they succeeded, and you figure the probability of being successful on each turn is roughly 10%? In R, if you wanted to simulate 1000 competitors in this model and plot the results, you'd do:

s <- rbinom (1000, 100, 0.1)
plot (table (s))

You actually mentioned "fail" and it sounds like at that point the person is out of the game. So perhaps you're envisioning a game where you get up to 100 turns, but the first time you fail you're out and forfeit further turns. This sounds like the Negative Binomial distribution, which "represents the number of failures which occur in a sequence of Bernoulli trials before a target number of successes is reached.", where you're swapping the role of "failure" and "success" to get "the number of successes in a sequence before a target number of failures is reached" and your target number of failures is 1.

If you assume that people are successful on their turn 95% of the time, in R, this would be:

s <- rnbinom (1000, 1, 0.05)
plot (table (s))

That is, simulate 1000 contestants, up to their first "success" (actually "failure"), where the probability of "success" is only 5% (that is, the probability of failure is only 5%).

Make sense? You can get more sophisticated, too. You might say, "Well, the negative binomial thing is a lot like what I imagined, but now that I think of it, there are really two groups of people playing my game: the Casuals, and the Competitors. The Casuals probably have a 80% chance of success each turn, overall, while the Competitors are younger and more competitive (and play the game more often) so probably have a 97% change of success on each turn. For every 1000 Casuals, there are about 250 Competitors:

s <- c(rnbinom (1000, 1, 0.20), rnbinom (1000, 1, 0.03)

(where c combines your results into a single list) and so on.

We've got to be honest with ourselves, though: these simple models are not the real world. What if the odds of success decrease for Casuals, the more turns they compete, while the odds of success increase for Competitors, right up until they become the leaders, in which case they have a good chance of choking under pressure? Whew! It's of course possible to turn all of that into a numerical simulation as well, but even if we do, we still can't pretend that such a simple model accurately mimics the real world.

But it still might be more illuminating than just making up numbers across a range of conditions as the first alternative does. People are, in general, pretty poor at kind of task.

$\endgroup$
1
  • $\begingroup$ Great response! To clarify- the game is assumed to be an infinite progression game, so a user COULD, theoretically, get to 1 million points, but it's highly unlikely. (For simplicity, I'm saying a user maxes at some number and can't get any higher.) As a 1 player game, the user only gets 1 turn, but can always play again- although that shouldn't affect the outcome of the overall list of scores. What I'm really trying to get to is a single function that, when run once, is an apparently random number, however, when run 100,000 times, and the results plotted, shows a skewed regular distribution. $\endgroup$ Commented Jan 27, 2016 at 19:15
0
$\begingroup$

Many people know that the maximum entropy distribution that requires a finite first and second moments and infinite domain is the normal distribution.

However, the maximum entropy distribution that requires a finite first and second moments without no domain limitations is not the normal; it is the supernormal (or disco-normal) distribution. [I prefer supernormal but that is commonly used to refer to other things and can cause confusion.]

The supernormal distribution is obtained by using Lagrange multipliers but you simply do not integrate to infinity. Amazingly, the supernormal form looks rather familiar:

$f(x,a,b)=\int_a^xe^{-(z-m)^2/s}dz/K(a,b)$

where

$K(a,b)=\int_a^be^{-(z-m)^2/s}dz$

is a normalizing factor (but it does depend on the domain).

If $a$ and $b$ are known, $K(a,b)$ can be computed easily and the expression can be inverted to generate random numbers.

Notes about the supernormal:

  • $m$ is not the mean, in general.
  • $s$ is not the variance, in general.
  • $s$ can be negative.
  • the distribution is not symmetric, can be skewed.
  • the distribution can be "L"-shaped, "J"-shaped, and "U"-shaped depending upon the choice of parameters.
  • its "U"-shape is not symmetrical, either.
  • if $m$ is centered between $a$ and $b$, the distribution is symmetric as a bell-shape or a U-shape.
  • You can derive the form of the mean and variance.
  • It is most easily used if you know $a$ and $b$...which, conveniently, you do.
  • The distribution can use discrete or continuous factors (hence DisCo Normal)...it does not require continuous responses.

This may not be the way you wanna go...just FYI.

$\endgroup$
0
$\begingroup$

So I understand the question as asking for an algorithm to generate random numbers according to a given pdf shape.

So a common way of generating random numbers from an "arbitrary" 1D distribution is to use the inverse CDF. First

  1. Come up with your desired pdf.
  2. calculate the cumulative distribution function
  3. calculate the inverse function (eg by lookup table) icdf(U)

Then to generate a new random number x, with desired pdf

  1. generate a uniform between 0 and 1, eg $u=.3$
  2. output the corresponding value of the inverse CDF $x=icdf(0.3)$
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.