数学方程可能无限循环吗?

发布于 2024-07-14 08:49:52 字数 411 浏览 8 评论 0 原文

我遇到以下问题,并且无法理解方程的一部分:

估计积分的蒙特卡罗方法基本上是采用大量随机样本并确定加权平均值。 例如,f(x) 的积分可以通过

r 估计="nofollow noreferrer">替代文本 http://www.goftam.com/images/area.gif

表示 xr 在 [x1, x2] 范围内的均匀概率分布。 由于每个 函数求值 f(xr) 是独立的,很容易分配这项工作 超过一组流程。

我不明白 f(xr) 应该做什么? 它是否反馈到同一个方程中? 那不是无限循环吗?

I have the following problem, and am having trouble understanding part of the equation:

Monte Carlo methods to estimate an integral is basically, take a lot of random samples and determined a weighted average. For example, the integral of f(x) can be estimated from N independent random samples xr by

alt text http://www.goftam.com/images/area.gif

for a uniform probability distribution of xr in the range [x1, x2]. Since each
function evaluation f(xr) is independent, it is easy to distribute this work
over a set of processes.

What I don't understand is what f(xr) is supposed to do? Does it feed back into the same equation? Wouldn't that be an infinite loop?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

飘逸的'云 2024-07-21 08:49:52

应该说 f(xi)

f() 是我们尝试通过数值蒙特卡罗方法积分的函数,该方法通过评估积分中随机选择的点来估计积分(及其误差)地区。

参考

It should say f(xi)

f() is the function we are trying to integrate via the numerical monte carlo method, which estimates an integral (and its error) by evaluating randomly choosen points from the integration region.

Ref.

旧城空念 2024-07-21 08:49:52

您的目标是计算 fx1x2 的积​​分。 例如,您可能希望计算 sin(x)0pi 的积​​分。

使用蒙特卡洛积分,您可以通过在区间 [x1,x2] 中采样随机点并在这些点评估 f 来近似这一点。 也许您想将此称为 MonteCarloIntegrate( f, x1, x2 )

所以,MonteCarloIntegrate 不会“反馈”到自身。 它调用函数f,即您尝试进行数值积分的函数,例如sin

Your goal is to compute the integral of f from x1 to x2. For example, you may wish to compute the integral of sin(x) from 0 to pi.

Using Monte Carlo integration, you can approximate this by sampling random points in the interval [x1,x2] and evaluating f at those points. Perhaps you'd like to call this MonteCarloIntegrate( f, x1, x2 ).

So no, MonteCarloIntegrate does not "feed back" into itself. It calls a function f, the function you are trying to numerically integrate, e.g. sin.

金橙橙 2024-07-21 08:49:52

f(x_r) 替换为 f(x_r_i​​) (阅读:f 在 x sub r sub )。 r_i 是从区间 [x_1, x_2] 中均匀随机选择的。

要点是:[x_1, x_2]f 下的面积等于 (x_2 - x_1) 乘以 的平均值>f 位于区间 [x_1, x_2] 上。 也就是说,

A = (x_2 - x_1) * [(1 / (x_2 - x_1)) * int_{x_1}^{x_2} f(x)\, dx]

方括号中的部分是 [x_1, x_2]f 的平均值,我们将其表示为 avg(f)。 我们如何估计f的平均值? 通过在 N 个随机点进行采样,并取在这些随机点评估的 f 的平均值。 也就是说:

avg(f) ~ (1 / N) * sum_{i=1}^{N} f(x_r_i)

其中x_r_1, x_r_2, ..., x_r_N是从[x_1, x_2]中均匀随机选择的点。

那么

A = (x_2 - x_1) * avg(f) ~ (x_2 - x_1) * (1 / N) * sum_{i=1}^{N} f(x_r_i).

这里是思考这个方程的另一种方式:区间 [x_1, x_2]f 下的面积与长度为 的矩形的面积相同>(x_2 - x_1) 且高度等于 f 的平均高度。 f 的平均高度大约

(1 / N) * sum_{i=1}^{N} f(x_r_i)

是我们之前生成的值。

Replace f(x_r) by f(x_r_i) (read: f evaluated at x sub r sub i). The r_i are chosen uniformly at random from the interval [x_1, x_2].

The point is this: the area under f on [x_1, x_2] is equal to (x_2 - x_1) times the average of f on the interval [x_1, x_2]. That is

A = (x_2 - x_1) * [(1 / (x_2 - x_1)) * int_{x_1}^{x_2} f(x)\, dx]

The portion in square brackets is the average of f on [x_1, x_2] which we will denote avg(f). How can we estimate the average of f? By sampling it at N random points and taking the average value of f evaluated at those random points. To wit:

avg(f) ~ (1 / N) * sum_{i=1}^{N} f(x_r_i)

where x_r_1, x_r_2, ..., x_r_N are points chosen uniformly at random from [x_1, x_2].

Then

A = (x_2 - x_1) * avg(f) ~ (x_2 - x_1) * (1 / N) * sum_{i=1}^{N} f(x_r_i).

Here is another way to think about this equation: the area under f on the interval [x_1, x_2] is the same as the area of a rectangle with length (x_2 - x_1) and height equal to the average height of f. The average height of f is approximately

(1 / N) * sum_{i=1}^{N} f(x_r_i)

which is value that we produced previously.

风吹雪碎 2024-07-21 08:49:52

无论是 xi 还是 xr 都无关紧要——它是我们输入到函数 f() 中的随机数。

我更有可能将函数(除了格式之外)编写如下:

(x2-x1) * sum(f(xi))/N

这样,我们可以看到我们取 f(x) N 个样本的平均值来获得函数的平均高度,然后乘以宽度 (x2-x1)。

因为归根结底,积分只是计算曲线下的面积。 (漂亮的图片位于 http://hyperphysicals.phy-astr.gsu。 edu/Hbase/integ.html#c4

Whether it's xi or xr is irrelevant - it's the random number that we're feeding into function f().

I'm more likely to write the function (aside from formatting) as follows:

(x2-x1) * sum(f(xi))/N

That way, we can see that we're taking the average of N samples of f(x) to get an average height of the function, then multiplying by the width (x2-x1).

Because, after all, integration is just calculating area under the curve. (Nice pictures at http://hyperphysics.phy-astr.gsu.edu/Hbase/integ.html#c4.

风为裳 2024-07-21 08:49:52

x_r 是积分范围内的随机值。

用 Random(x_1, x_2) 替换 x_r 将给出等效方程。

x_r is a random value from the integral's range.

Substituting Random(x_1, x_2) for x_r would give an equivalent equation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文