2
$\begingroup$

Give an approach to generate 50 elements between 1 to 1000 with negative skewness.

$\endgroup$
4
  • 1
    $\begingroup$ If you modify your question slightly so that it asks about approaches for generating data with negative skewness (rather than appearing to ask for R code) it is likely to be on topic. However, you'd have to explain more about what characteristics you need (you haven't even indicated whether you need continuous or discrete outcomes) $\endgroup$ – Glen_b Dec 24 '16 at 1:38
  • 1
    $\begingroup$ Do you want continuous data, or discrete data? Do the bounds (1, & 1000) have to be absolute? How much skewness do you want? $\endgroup$ – gung - Reinstate Monica Dec 24 '16 at 13:36
  • $\begingroup$ discrete data and skewness must be negative $\endgroup$ – Dumb Scientist Dec 24 '16 at 15:02
  • $\begingroup$ Generate 50 values between $1$ and $1000$ using (literally) any technique you like. Compute their skewness. If it is positive, subtract all values from $1001.$ If it is exactly $0,$ start over. $\endgroup$ – whuber Aug 3 '18 at 14:52
1
$\begingroup$

One simple way:

Generate independent U1 and U2 being uniform over the required range. Take the larger of the two. This will give one draw from a left skew discrete distribution.

Just repeat as many times as you like.

Example in R:

x <- replicate(50,max(sample(1000,2,replace=TRUE)))
x 
[1] 676 417 513 449 952 424 864 731 801 623 989 596 318 541 607 389 202 639 721
[20] 927 828 289  77 525 927 861 425 948 633 910 835 526 734 914 937 349 625 713
[39] 959 420 738 824 812 697 824 745  76 913 803 650

histogram of 50 points on 1,2,...,1000 with left skew distribution

(Of course in R you could simply specify an increasing set of p's in a single call to sample but this approach is easy in a variety of languages)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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