## 511 Reputation

18 years, 304 days

## I've done a proc to produce...

I've done a proc to produce a list of compound Poisson random variables as below, but it's not fast enough. I suspect there are better ways to do the same. Comments and solutions welcome! with(Statistics): FFFF := proc (g) local i, x, y, S; for i to g do x[i] := floor(convert(Sample(RandomVariable(Poisson(1)), 1), `+`)); if 0 < x[i] then y[i] := floor(convert(Sample(RandomVariable(Poisson(1)), x[i]), `+`)) else y[i] := 0 end if end do; S := [seq(y[i], i = 1 .. g)] end proc; T := time(); FFFF(1000); time()-T; That would produce 10 times longer sequence of the form [1, 0, 4, 0, 3, 2, 1, 2, 2, 0]. Can I use seq or anything else to make it faster? Can I define variables, e.g., g_i:=2 within the seq environment. Thanks.

## I've done a proc to produce...

I've done a proc to produce a list of compound Poisson random variables as below, but it's not fast enough. I suspect there are better ways to do the same. Comments and solutions welcome! with(Statistics): FFFF := proc (g) local i, x, y, S; for i to g do x[i] := floor(convert(Sample(RandomVariable(Poisson(1)), 1), `+`)); if 0 < x[i] then y[i] := floor(convert(Sample(RandomVariable(Poisson(1)), x[i]), `+`)) else y[i] := 0 end if end do; S := [seq(y[i], i = 1 .. g)] end proc; T := time(); FFFF(1000); time()-T; That would produce 10 times longer sequence of the form [1, 0, 4, 0, 3, 2, 1, 2, 2, 0]. Can I use seq or anything else to make it faster? Can I define variables, e.g., g_i:=2 within the seq environment. Thanks.
 1 2 Page 2 of 2
﻿