1
$\begingroup$
p[j_] := A*Sin[(Pi/2)*(j/(numpts + 1))]
A = 16;
numpts=256;
steps = Table[
   RandomVariate[PoissonDistribution[p[j]]], {j, 1, 256}] + 1
steplist = Take[steps, 65]
timepoints = Table[0, {i, 65}];
Do[timepoints[[i + 1]] = timepoints[[i]] + steplist[[i]], {i, 
  Length[timepoints] - 1}]

timepoints

I want to get the timepoints such that the number picked from steps yields timepoints less than or equal to 256. The loop should run again if the number picked is greater than 256 until all the numbers are less than 256.

Something like:

While[Sum[steplist[[i]], {i, 65}]]
Do[steps = Table[
   RandomVariate[PoissonDistribution[p[j]]], {j, 1, 256}] + 1]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.