I need to apply Monte Carlo integration to a function using R. I am able to plot the equation, but am unaware on how to plot random points over it.
Would appreciate any insight on how to do that.
The function I’m using to plot, is the basic plot() function with x as the desired range and y as the equation.
Thank you.
The nicest way to plot a curve is to use the
curvefunction:You can then add points to the plot via the
pointsfunction:and calculate the Monte-Carlo estimate using a comparison: