First shot at coding MCI. I can't figure out how to generate random floating point integers which would probably increase the accuracy of my results, so for now I am just generating random integer ordered pairs.
Still, my results are way off even with a large sample size. Where am I going wrong? Is it a conceptual issue? Or a programming logic error?
(1) You are trying to approximate an integral ... but all your test points are integers (lines 28 and 29). This will seriously bias whether your y values lie under the curve or not, which is what you are trying to find the fraction of. Consider using the uniform real-number distribution in <random>.
(2) You don't need tP (it is the same as the sample size).
(3) Use sqrt rather than pow(.,0.5). Don't bother to find 0 to any power. Use 2.0/3 rather than the inaccurate 0.667.
(4) If you want to make your program more useful, put functionY in a separate function, rather than hard-coding it in int main().
The logic for the Monte-Carlo method is OK (find the fraction of the points lying under the curve and then multiply by the outer rectangular area). The random-number generation is wrong: you are making it discrete when it should be continuous.
I went ahead and implemented a continuous random number generator using the uniform real-number distribution. I'm still getting results way off however.
Thank you for all your help! I really appreciate it.