• We are pleased to announce that the winner of our Feedback Prize Draw for the Winter 2024-25 session and winning £150 of gift vouchers is Zhao Liang Tay. Congratulations to Zhao Liang. If you fancy winning £150 worth of gift vouchers (from a major UK store) for the Summer 2025 exam sitting for just a few minutes of your time throughout the session, please see our website at https://www.acted.co.uk/further-info.html?pat=feedback#feedback-prize for more information on how you can make sure your name is included in the draw at the end of the session.
  • Please be advised that the SP1, SP5 and SP7 X1 deadline is the 14th July and not the 17th June as first stated. Please accept out apologies for any confusion caused.

Monte Carlo Simulation - Speed of convergence

E

Edwin

Member
I just performed the simulation exercise to estimate pi, however my simulation is nowhere close to 3.1428.... the average value is around 2! :(

Surprisingly i used 4177 different values of the (x,y) coordinates since it failed to convergence for the first 100 as suggested by table 20.1 of Hull, 8th edition. I don't know what's wrong since I checked the excel formulas many times.

On the other hand the simulation I did to price the Option struck at 50 as in table 20.2 converges very quickly to the Black Scholes price of 4.817.

Could there be a reason why the two converge at varying speeds or why the pi one converges to a wrong value for 4000 diff coordinates?
 
I just performed the simulation exercise to estimate pi, however my simulation is nowhere close to 3.1428.... the average value is around 2! :(

Surprisingly i used 4177 different values of the (x,y) coordinates since it failed to convergence for the first 100 as suggested by table 20.1 of Hull, 8th edition. I don't know what's wrong since I checked the excel formulas many times.

On the other hand the simulation I did to price the Option struck at 50 as in table 20.2 converges very quickly to the Black Scholes price of 4.817.

Could there be a reason why the two converge at varying speeds or why the pi one converges to a wrong value for 4000 diff coordinates?

I actually tried this a couple of years back in MATLAB and faced the same issue - even after 1 billion simulations!

Code:
%  Monte Carlo computation of pi.

n = input(' Enter n: ');
count = 0;

for i=1:n,
  x = 2*rand-1;  y = 2*rand-1;
  if x^2 + y^2 <= 1,  
  count = count + 1;  
  end;
end;

pi_approx = 4*(count/n);

I think the difference could be because of the use of pseudo random numbers rather than actually random numbers. I'd be grateful too if someone else can shed more light on this.
 
Last edited:
I actually tried this a couple of years back in MATLAB and faced the same issue - even after 1 billion simulations!

I think the difference could be because of the use of pseudo random numbers rather than actually random numbers. I'd be grateful too if someone else can shed more light on this.

But even though the author does mention that the speed of convergence is slow for this example, suggesting a value of 3.04 for 100 coordinates is misleading, but that's only if other people faced the difficulty that I and you faced.
 
I actually tried this a couple of years back in MATLAB and faced the same issue - even after 1 billion simulations!

Code:
%  Monte Carlo computation of pi.

n = input(' Enter n: ');
count = 0;

for i=1:n,
  x = 2*rand-1;  y = 2*rand-1;
  if x^2 + y^2 <= 1,  
  count = count + 1;  
  end;
end;

pi_approx = 4*(count/n);

After running your code, I found that the Matlab simulation is more than 150% better than the one I did it excel, in-fact for 1 billion simulations it gave 3.1417, not quite bad, it doesn't converge absolutely but it's not that far away from pi!

I still wonder why mine is that WAY off??
 
Last edited by a moderator:
Something is probably wrong if you run the simulation many times and get pi=2. What are you using as random numbers?

I got 3.08 for 100 random dots in a square type simulation, but this is by chance. If you run it again it varies (expected as your input is supposed to be a random variable).

Not sure why you'd expect the two monte carlo simulations to have similar speeds. They are very different in most aspects. You can analyse how fast they converge (variance, estimation error etc) but apples and oranges.

As for running these things for a billion simluations, that might be a bit spurious. You'd need to make sure you're using a suitable random generator that can generate enough random values. Most generators repeat after a while.
 
Last edited by a moderator:
For the unit circle estimation method, you should be getting values pretty consistently around three with n=50. It is however a pretty slow technique - it's not even stable to one decimal place at n=10000. I'm never sure why it's such a favourite for introducing Monte Carlo methodology.
 
For the unit circle estimation method, you should be getting values pretty consistently around three with n=50. It is however a pretty slow technique - it's not even stable to one decimal place at n=10000. I'm never sure why it's such a favourite for introducing Monte Carlo methodology.


I gave up, I was possibly doing something wrong, still don't know what?
 
Odd, certainly.

Have you tested the psuedo random values generated? A scatterplot of your x,y values would reveal any obvious problems.

Excel's RNG is poor quality, especially in <2007 versions, but you don't need high quality randomness for this sort of application.
 
Back
Top