Oops, beside the problem caused probably by too long comments, there remains
a sing error in line 12. Of course you also loaded the required 'stats'
file.
profits should therefore read:
profits=: 4 : 0
NB. average profit during m years
'i l c h K k p s S'=.y
NB.x: number of years
NB.i: initial
m=.x[pr=.0
ps=.poissonrand l, m
for_t. i.m do.
v=. i<.t{ps NB. sales Poisson with mean l
NB. bring inventory to level S if it falls below s
NB. with probability p of receiving merchandise
r=. (S-i-v)*(s>i-v)*.p>?0
pr=.pr+(c*v)-((i-v)*h)+(r>0)*K+k*r NB. profit for day
i=.0>.i+r-v
end.
pr%m NB. average daily profit
)
The correct result is then :
inventory''
sample size: 500
minimum: 83.9173
maximum: 85.9824
median: 84.9858
mean: 84.9811
std devn: 0.325074
skewness: _0.0454696
kurtosis: 3.04136
As for poissonrand, improvements should probably be contemplated. The one I
offered is technically correct, and would be useful at least in situations
where the sampling is to be an integer but it would not be recommended for a
small Poisson random sample. I am afraid I do not understand the basis of
your proposed variation, sorry.
I thank you for your interest and quick response.
Robert
On Fri, Aug 8, 2008 at 6:55 AM, Raul Miller <[EMAIL PROTECTED]> wrote:
> On Fri, Aug 8, 2008 at 6:25 AM, I wrote:
> > ps=.poissonrand l, m
>
> I should note that I got the same kinds of results from that
> program when I replaced the above line with:
> ps=. >.l % ([EMAIL PROTECTED]@[EMAIL PROTECTED] 0:) m
>
> --
> 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