SpTB / mob_project

1 stars 0 forks source link

Generative function bug #1

Open SpTB opened 3 years ago

SpTB commented 3 years ago

I've diagnosed the problem with the function, though I'm not sure what is the proper way to fix it. Here is the breakdown:

The Expected utility matrix riskyExpReward has incompatible dimentions with the loop. This happens only in the case of high sigma, because the dimentions of the matrix are independent of the sigma, while stepsOut variable depends on it:

riskyExpReward <- matrix(rep(0,n*numY),ncol = numY) stepsOut <- ceiling(8*sigma/dy)

Then, when the values are filled inside a for loop, stepsOut is used: for (j in (lowerCalcLim+1):upperCalcLim){ riskyExpReward[k,j]=sum(pmax(riskyExpReward[k+1,(j-stepsOut):(j+stepsOut)],safeReturns)*f)*dy }

In case of a sample set of parameters, where: n = 21 numY = 60000 sigma = 10

During the loop, when: j = 44001 (j+stepsOut) = 600001, which is 1 more than the number of rows of riskyExpReward.

Let me know how would you fix it. From my basic understanding, I'd think that if stepsOut is dependent on sigma, so should be the output matrix. Otherwise, there can always be a case where the dimentions won't line up.

pantelispa commented 3 years ago

I am not sure I follow here. We can try to resolve this online when we meet on the weekend.