Question

Does anyone have any ideas how to implement a monte carlo integration simulator in vb.net.

I have looked around the internet with no luck.

Any code, or ideas as to how to start it would be of help.

No correct solution

OTHER TIPS

Well i guess we are talking about a 2 dimensional problem. I assume you have a polygon of which you want to calculate the area.

1) First you need a function to check if a point is inside the polygon.

2) Now you define an area with a known size around the polygon.

3) Now you need random points inside your known area, some of them will be in your polygon, some will be outside, count them!

4) Now you have two relations: First the relations of all points to points inside your polygon. Second the area around your polygon which you know, to the area of the polygon you don't know.

5) The relations is the same --> you can calculate the area of your polygon! (Area of polygon should be: points in you polygon / all your points * size of known area)

Example: 3 points hits hit the polygon, 20 points where "shot", the area of the polygon is 0.6m² NOTE: This area is only an approach! The more points you have, the better the approach gets. enter image description here

You can implement a fancy method to display this in your vb program of course. Was this what you needed? Is my assumption about the polygon correct? Do you need help with the "point inside polygon" algorithm?

There is nothing specific to VB.net with this problem, except maybe for the choice of a random number generator from the library.

Numerically solving integrals of a function f(x_1,...,x_n) by using can become infeasible (in acceptable time) for high dimensions n, because the number of sample points needed for a given sampling distance grows exponentially with the dimension of the problem. The fundamental idea with Monte Carlo Integration is to replace the uniform sampling of the variables x_1,...,x_n with random sampling, taking n random numbers per sample. With these samples, estimate the integral. The more samples, the better the estimate. And the major benefit of MC integration is, that you can use standard statistical methods to estimate the error of your result.

So, how to start: Implement integration by uniform sampling of the integration space, then go to random sampling and add error estimation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top