Hello Mark, Exactly, thanks very much!
Dimos --- On Sat, 11/20/10, Mark Dickinson <dicki...@gmail.com> wrote: > From: Mark Dickinson <dicki...@gmail.com> > Subject: Re: Weibull distr. random number generation > To: python-list@python.org > Date: Saturday, November 20, 2010, 7:09 PM > On Nov 19, 3:21 pm, Dimos <dimos_anastas...@yahoo.com> > wrote: > > I would like to use the random module, and if I > understand well the Random class, to create 1300 decimal > numbers in python, by providing the 2 Weibull parameters > (b,c). How this can be done??? > > > > import random > > print random > > random.weibullvariate(b,c) > > How can I set the population size n=1300 in decimals? > > random.weibullvariate(b, c) generates a single sample from > the > specified Weibull distribution. If you want 1300 > samples, you'd use > this within a loop. For example, here's code to put > 10 Weibull > variates with scale parameter 12345.0 and shape parameter > 6.0 into a > list: > > >>> import random > >>> samples = [] > >>> for i in xrange(10): > ... > samples.append(random.weibullvariate(12345.0, > 6.0)) > ... > >>> print samples > [15553.186762792948, 14304.175032317309, > 9015.5053691933044, > 12585.469181732506, 9436.2677219460638, 13350.89758791281, > 5687.4330250037565, 12172.747202474553, > 9687.8685933610814, > 11699.040541029028] > > A more experienced Python programmer might use a list > comprehension to > achieve the same effect in a single line: > > >>> samples = [random.weibullvariate(12345.0, 6.0) > for _ in xrange(10)] > >>> print samples > [10355.396846416865, 14689.507803932587, > 11491.850991569485, > 14128.56397290655, 12592.739991974759, 9076.7752548878998, > 11868.012238422616, 12016.784656753523, > 14724.818462506191, > 13253.477389116439] > > Is this the sort of thing you were looking for? > > -- > Mark > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list