A spee-up is possible after all.  I simply run the 500 simulations at once.

profits2=: 3 : 0
pr=.500$0
'i l c h K k p s S'=.200,100,2,0.1,10,1,0.95,80,200
for. i.2000 do.
    v=. i<.100 poissonran 500             NB. sales poisson with mean l
    r=. (S-i-v)*(s>i-v)*.p>[EMAIL PROTECTED]     NB. bring inventory to level S 
if it
fals below s,
                                                                NB.
probability of delivering purchsed merchandise p
    pr=.pr+(c*v)-((i-v)*h)+(r>0)*K+k*r NB. to the cumulated profits, add the
day's profit
    i=.0>.i+r-v
end.
dstat pr%2000 NB. average daily profit
)

ts'profits2 0'

0.302445 66432

It may not be as easy to lump together the rest of the code.

*J is good*

Now  all that is missing is the students distribution.

Robert Cyr

On Sat, Aug 9, 2008 at 5:12 PM, Robert Cyr <[EMAIL PROTECTED]> wrote:

> For small means, the number of terms must be greater.  Taking no chances,
> and using 50 times the mean,
>
>
>
> limit=: 3 : 0
> NB. threshold for mean y
> (+/\(^-y)**/\1,y%}.i.50*y)I.1.0
> )
>
> limit 2
>
> 22
>
> and the cumulative distribution function reaches 1 only when x=22.
>
> plot(;limit"0)i.100
>
> Adjusting the comparison tolerance may be a solution.
>
>
> On Sat, Aug 9, 2008 at 4:44 PM, Raul Miller <[EMAIL PROTECTED]> wrote:
>
>> On Sat, Aug 9, 2008 at 4:37 PM, Robert Cyr <[EMAIL PROTECTED]> wrote:
>> > Sory about that
>> >
>> > try instead:
>> >
>> > plot(;limit"0)i.100
>>
>> That does succeed, mechanically.
>>
>> However:
>>   limit 2
>> 10
>>   >./poissonrand 2 1e6
>> 13
>>
>> --
>> Raul
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to