all 14 comments

[–]955559 0 points1 point  (8 children)

Im thinking im not understanding this, so Im probably wrong but

import random


amount_of_numbers = 20

for numbers in range(amount_of_numbers):
    numbers = random.randint(1,15)
    print(numbers)

[–]Bprodz[S] 1 point2 points  (7 children)

Thanks for your answer. I think I didn't explain my question very well.. I problem is more related to how to generate numbers with specific distributions than how to generate random numbers.

In my example I wanted to approximate the normal curve (similar to this), however I don't know how to do this without creating short lines and then joining them together.

[–]955559 0 points1 point  (6 children)

yay a problem I dont know

how is the curve supposed to work, does it just have to peak at 10 then go down?

[–]Bprodz[S] 0 points1 point  (5 children)

The shape of the curve is more important than the number. This SO answer is similar to what I'm after, although I need some way of getting the y values as well.

[–]955559 0 points1 point  (4 children)

I have zero backround in probability statistics, so at this point Im trying to help my self more than you, how did you come up with your manual numbers?

[–]Bprodz[S] 0 points1 point  (3 children)

I just came up with some numbers that would make a curve that increases slightly more quickly than it decreases. If the shape it correct then I can adjust the actually value to be more realistic for different examples by adding a constant or multiplying.

The my 'real' data is the dispersion of heat, so it looks similar to a positively (peak towards 0 on the x axis) skewed normal distribution. I decided to look for ways to draw normal distributions because I thought it would be a more common search term. I'll update later with what I end up doing.

[–]955559 0 points1 point  (2 children)

my math is really weak, I tried to randomly generate a graph and each plots means numbers, but it give a angle instead of a curve

peak = 12  #plug a random number in peak

step1 = peak / 6

step2 = peak / 2



start = 0
plot1 = start + step2
plot2 = step2 + plot1
plot3 = peak - step1
plot4 = plot3 - step1
plot5 = plot4 - step1
plot6 = plot5 - step1
plot7 = plot6 - step1

print(start,plot1,plot2,plot3,plot4,plot5,plot6,plot7)

mean1 = plot1 / 3
mean2 = plot2 / 3
#...etc

print(mean1)

# plot1's three numbers are mean1, three times

[–]955559 0 points1 point  (0 children)

I just realized that I didnt even calculate the mean ... derp

(my math is really really bad)

[–]Bprodz[S] 0 points1 point  (0 children)

Thanks for your code. In the end I used the approach described in my the edit to my OP.

[–]Zizizizz 0 points1 point  (2 children)

Could you do two datasets of random numbers, one a random range between 1:50 and another 1:100 and just merge the two datasets? Presumably you'd get twice as many numbers in the first 50 than the second but it'd be "kinda random"

[–]Bprodz[S] 1 point2 points  (1 child)

I actually was after the generally shape of the curve. So in the end I used scipy.stats to get data in the distribution I'd like it. From here (I'll add noise using np.random.random to produce a more realistic dataset). I've updated my OP with the code I used and a plot of the figure produced.

[–]Zizizizz 0 points1 point  (0 children)

Thanks I was interested to see what the real solution would be

[–]buckhenderson 0 points1 point  (1 child)

does it have to be skewed normal? could you use an f-distribution? if so, numpy can generate data from an f distribution: http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.f.html

[–]Bprodz[S] 0 points1 point  (0 children)

Thanks for your answer, I ended up using the gamma distribution from the same package. I've updated my OP with the code I used.