蒙特卡洛法的体积 [英] Volume with Monte Carlo method

查看:267
本文介绍了蒙特卡洛法的体积的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题.我必须构建一个程序,以使用蒙特卡洛方法计算立方体的体积.多维数据集在XYZ轴上以(0,0,0)开头.也可能有一些领域.球体可以在立方体中,然后立方体的体积为:=立方体体积. -球体积该球体也可以位于立方体之外.我知道这种方法的工作原理,但是我很难定义随机点的间隔(我只知道用这种方法计算积分).参数为:a-立方体边的长度,点-(X,Y,Z)为球心的点,r-半径.例如a = 1,point1 =(0,0,0),r1 = 0.5,point2 =(1.25,1.25,1.25)r2 = 0.25.在这种情况下如何确定随机点的间隔?

I have a question. I must build a program to calculate a volume of a cube with Monte Carlo method. Cube has a beginning in (0,0,0) on XYZ axis. There can also be some spheres. The spheres can be in cube then the volume of cube is := cube vol. - sphere vol. This sphere can also be outside the cube. I know how this method works but i have problem to define interval of random points ( i only know to calculate an integral with this method). The parameters are: a - lenght of cube side, point - (X,Y,Z) point which is center of sphere, r -radius. For example a = 1, point1 = (0,0,0), r1 = 0.5, point2 = (1.25,1.25,1.25) r2 = 0.25. How to determine interval of random points in this situation?

推荐答案

点的间隔必须至少为 多维数据集本身的间隔.它可以大于多维数据集的间隔,并且您仍然可以使算法起作用,但是计算效率较低.它不能小于多维数据集本身的间隔,否则您将得到错误的答案.

The interval of your points must be at least the interval of the cube itself. It can be more than the interval of the cube and you can still make the algorithm work, but it will be less computationally efficient. It cannot be less than the interval of the cube itself or you will get the wrong answer.

详细信息:

您总是想对点进行分类:立方体内的点与立方体内的点,而不是球体内的点.第一类与第二类的比率是立方体的体积与未被球体占据的立方体的体积之比. (从技术上讲,随着点数的增加,一个比率接近另一个比率.)

You always want to come up with a classification of points: Points inside the cube, vs points inside the cube but not inside a sphere. The ratio of the first class to the second class is the ratio of the volume of the cube to the volume of the cube that is not occupied by a sphere. (Technically, the one ratio approaches the other ratio as the number of points increases.)

因此,请考虑以下三种情况:

So consider your three cases:

如果采样间隔恰好是立方体的间隔,则分类很简单.所有的分数都在头等舱.您只需通过对照所有球体检查每个点来确定第二类.

If your sampling interval is exactly the interval of the cube, your classification is simple. All the points are in the first class. You determine the second class just by checking each point against all the spheres.

如果采样间隔大于多维数据集的间隔,则将在方程中引入新的一类点:点甚至不在多维数据集中.现在,不仅需要针对多维数据集测试每个点,而且不在多维数据集中的点也无济于事.它们根本不会被使用,因为它们不在任何对您有帮助的类别中.您完全没有目的地做一些工作.

If your sampling interval is larger than the interval of the cube, you are introducing a new class of points into the equation: points that are not even in the cube. Not only do you now need to test each point against the cube, the points that are not in the cube are useless. They do not get used at all because they are not in any category that helps you. You are doing some fraction of work for no purpose at all.

如果采样间隔小于多维数据集的间隔,则出于显而易见的原因,这根本不起作用-您没有在多维数据集的整个体积上进行采样,因此某些区域不是(进行统计)调查,无论您做什么都将得出错误的比率.

If your sampling interval is smaller than the interval of the cube, then this doesn't work at all for obvious reasons-- you're not sampling over the whole volume of the cube and so there are regions you are not (statistically) investigating, and you will approach the wrong ratio no matter what you do.

因此,其中一种情况不起作用;另一种情况恰好满足您的要求,仅此而已;第三种情况可以工作,但可以完成一定程度的工作,这实际上是无用的和浪费的.

So one of these cases won't work; another case does exactly what you need it to do and nothing more; and the third case can be made to work but does a certain fraction of work that is literally useless and wasteful.

这篇关于蒙特卡洛法的体积的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆