On Dec 28, 8:13 pm, akm <andrew.mussel...@gmail.com> wrote:
> Hi all, can anyone recommend a way of generating random numbers via a
> Poisson distribution?
>
> I'm trying to wrangle scipy.stats.poisson to get something centered at
> 10, say, with a nice long tail out to the right, but I can't figure
> out how to manipulate the shape of the the distribution.
>
> Here's the code I'm using:
>
> from scipy.stats import poisson
> moo = 10
> p = poisson(moo)
> dist = p.rvs((100000,)).tolist()
> s=stats.TimeSeries(dist).plot_histogram(bins=172, normalize=False,
> color='black')
> s.show(xmin=0, xmax=50, aspect_ratio=.001)
>
> The docs for poisson() suggest I can change loc, scale, size, and
> shape, but I can't figure out the syntax.
>
> If there's a better way I'd love to hear about it also.
>
> Thanks!
>
> Best
> Andrew


sage: from scipy import stats
sage: sage: stats.poisson.rvs(10,loc=0.0,scale=1.0,size=100)
array([10, 15,  8,  8, 14, 11,  9, 11, 12,  8,  8, 17, 12, 18, 20,
3,  9,
        8,  4, 16,  9, 13,  3,  9, 11, 10, 17,  8,  8,  6, 11, 13, 11,
10,
       10, 13,  9, 10,  9, 13, 11,  9,  9, 13,  7,  9,  8, 14, 10,  4,
11,
        8, 11,  5,  8,  8, 14,  6, 14,  6, 11,  9, 10,  8,  6,  4, 10,
18,
       12, 10, 17,  6, 10,  9,  9, 15, 17,  7, 10,  5,  9, 12,  6,
9,  3,
        3, 11, 12, 13, 10,  4, 12, 12, 13, 13, 14, 14, 10, 12, 15])

http://oneau.wordpress.com/2011/02/28/simple-statistics-with-scipy/

http://docs.scipy.org/doc/scipy/reference/tutorial/stats.html

sage: maxima('load(distrib)')
sage: maxima('random_poisson(1,10)')
[0,1,0,0,0,2,0,0,0,1]
sage: maxima('random_poisson(10,10)')
[16,15,9,14,8,7,12,8,10,6]

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to