[EMAIL PROTECTED] wrote:
> attackwarningred napisa (a):
> 
> 
>>The array F(n) is dynamically allocated earlier on and is sized with
>>reference to shotcount, the number of iterations the model performs. The
>>problem is I can't get something like this to run in Python using numpy,
>>and for the size of the array to be sized dynamically with reference to
>>the variable shotcount. I acknowledge that my knowledge of Python is
>>still really basic (I only started learning it a few days ago) and I'm
>>trying to get out of the Fortran programming mindset but I'm stuck and
>>don't seem to be able to get any further. If anyone could help I'd be
>>really grateful. Thanks very much in advance.
> 
> 
> Hello. If you want your array to be dynamically resized at every loop
> iteration, that might be quite inefficient. How about initialising it
> with a required size?
> 
> F = numpy.array([0]*shotcount)
> for n in xrange(shotcount):
>         F[n] = random.lognormvariate(F_mean, F_sd)
> 
> Hope that helps,
> Marek
> 

or,

F = numpy.random.lognormal(F_mean, F_sd, shotcount)

(assuming F_mean, F_sd are the parameters of the distribution, rather
than the actual mean and standard deviation).

Duncan
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to