You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助求解含求和项的高斯积分:∫ₐᵇ[exp(-∑ᵢ₌₁ⁿ(rᵢ-A)²)/A]dA

求解高斯积分 $\int_{a}^{b}\frac{\exp\left(- \sum_{i=1}^n(r_i - A)^{2}\right)}{A} dA$

Hey fellow tech peers, let's work through this Gaussian integral problem step by step. We'll start by simplifying the integrand to make it more manageable, then cover both exact solutions using special functions and practical approximations for real-world use cases.

Step 1: Simplify the Exponential Term

First, let's expand the sum inside the exponential to rewrite it in a more friendly form:
$$
\sum_{i=1}^n (r_i - A)^2 = \sum_{i=1}^n (A^2 - 2r_i A + r_i^2) = nA^2 - 2A\sum_{i=1}^n r_i + \sum_{i=1}^n r_i^2
$$
To clean this up, define two shorthand variables:

  • $\bar{r} = \frac{1}{n}\sum_{i=1}^n r_i$ (the sample mean of the $r_i$ values)
  • $S = \sum_{i=1}^n r_i^2$ (the sum of squares of the $r_i$ values)

Using these, we can complete the square for the quadratic in $A$:
$$
\sum_{i=1}^n (r_i - A)^2 = n(A - \bar{r})^2 + (S - n\bar{r}^2)
$$
This lets us rewrite the original integral as a constant factor times a simpler integral:
$$
\exp\left(n\bar{r}^2 - S\right) \int_{a}^{b} \frac{\exp\left(-n(A - \bar{r})^2\right)}{A} dA
$$
The exponential term outside the integral is just a constant (it doesn't depend on $A$), so now we only need to solve the integral $I = \int_{a}^{b} \frac{\exp\left(-n(A - \bar{r})^2\right)}{A} dA$.

Step 2: Exact Solution Using Special Functions

Unfortunately, this integral doesn't have a closed-form solution with elementary functions. But we can express it using standard special functions and series expansions:

Variable Substitution & Series Expansion

Let's make a substitution to standardize the Gaussian term: let $x = \sqrt{n}(A - \bar{r})$, so $A = \bar{r} + \frac{x}{\sqrt{n}}$ and $dA = \frac{dx}{\sqrt{n}}$. Substituting into $I$ gives:
$$
I = \frac{1}{\sqrt{n}} \int_{\sqrt{n}(a - \bar{r})}^{\sqrt{n}(b - \bar{r})} \frac{\exp(-x^2)}{\bar{r} + \frac{x}{\sqrt{n}}} dx
$$

If $\left|\frac{x}{\bar{r}\sqrt{n}}\right| < 1$ (which holds when $\bar{r}$ is large relative to the Gaussian width $\frac{1}{\sqrt{n}}$), we can use the geometric series expansion $\frac{1}{1+z} = \sum_{k=0}^\infty (-1)^k z^k$ to rewrite the denominator:
$$
\frac{1}{\bar{r} + \frac{x}{\sqrt{n}}} = \frac{1}{\bar{r}} \sum_{k=0}^\infty (-1)^k \left( \frac{x}{\bar{r}\sqrt{n}} \right)^k
$$
Substituting this back into $I$ and integrating term-by-term (the series converges uniformly for bounded $x$), we get:
$$
I = \frac{1}{\bar{r}\sqrt{n}} \sum_{k=0}^\infty \frac{(-1)k}{(\bar{r}\sqrt{n})k} \int_{\sqrt{n}(a - \bar{r})}^{\sqrt{n}(b - \bar{r})} x^k \exp(-x^2) dx
$$
Each integral $\int x^k e{-x2} dx$ can be solved recursively:

  • For even $k=2m$: Use reduction formulas to express it with elementary functions
  • For odd $k=2m+1$: It simplifies to a polynomial times $e{-x2}$

Step 3: Practical Approximations

For many real-world scenarios (e.g., large $n$ where the Gaussian is tightly peaked around $\bar{r}$), we can approximate $A \approx \bar{r}$ over the region where the Gaussian is non-negligible. This simplifies the integral drastically:
$$
I \approx \frac{1}{\bar{r}} \int_{a}^{b} \exp\left(-n(A - \bar{r})^2\right) dA
$$
The integral here is a standard Gaussian integral, solvable using the error function $\text{erf}(x)$:
$$
\int_{a}^{b} \exp\left(-n(A - \bar{r})^2\right) dA = \frac{\sqrt{\pi}}{2\sqrt{n}} \left[ \text{erf}\left(\sqrt{n}(b - \bar{r})\right) - \text{erf}\left(\sqrt{n}(a - \bar{r})\right) \right]
$$
Putting it all together, the original integral approximates to:
$$
\exp\left(n\bar{r}^2 - S\right) \cdot \frac{\sqrt{\pi}}{2\bar{r}\sqrt{n}} \left[ \text{erf}\left(\sqrt{n}(b - \bar{r})\right) - \text{erf}\left(\sqrt{n}(a - \bar{r})\right) \right]
$$
This approximation works extremely well when the Gaussian peak is narrow and the bounds $a,b$ cover most of the peak's area.


内容的提问来源于stack exchange,提问作者Wahdan Muath

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 06:47:27