Hello, I have been searching for an alternative for my problem, but wasn't really able to get a convenient solution.
Issue with randn:
Although randn is based on zero mean, it doesn't really produce an array with zero mean. Even if I generate 1 million random variables from the standard normal, the mean sometimes is "far" from zero (ex: 0.003). I really need zero mean generations. I can't simply deduct the mean, as I need to use the numbers generated in simulating new stock prices, this moves me to my specific issue.
Issue with my case:
To simplify it to the maximum, please consider the following algorithm:
for i=1:j Step 1 StockPrice %Given
Step 2 %Some calculations
Step 3 StockPrice = StockPrice*randn %Generating new stock price
Step 4 %Some calculations Step 5 StockPrice = StockPrice*randn %Generating new stock priceend
I really don't want to complicate my code with if statements to achieve the zero mean. Kindly note that generating one vector of random numbers will be much faster than my current method.
My problem will be solved if there is a way to move in a vector in every iteration.
Thanks in advance
Best Answer