Reputation: 1576
How do you generate a skewed distribution with just the size, lower bound, and upper bound? Initially, there is no data and I think I just need to generate data randomly but after that how do you make it skewed?
Upvotes: 0
Views: 675
Reputation: 19854
Any asymmetric distribution is skewed, you just have to pick one and go with it. One of the easiest choices would be to use a triangular distribution. If U
is a uniformly distributed random number between 0 and 1, low
is the lower bound, and high
is the upper bound, you can generate random variates X
which have a maximally left-skewed right-triangular distribution with
X = low + (high - low) * sqrt(U)
For a maximally right-skewed version
X = low + (high - low) * (1 - sqrt(U))
For a less skewed result, use the generalized triangle generation algorithm from the linked Wikipedia page. As long as the mode of the triangle is not the mid-range value, the result will be skewed. As the mode is moved closer to either end of the range the distribution becomes more skewed
Upvotes: 2