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

求像素位置重排生成的图像总数及欧氏距离平均值

Alright, let's break down this problem step by step—first the total number of possible Inew images, then the average Euclidean distance between I and all Inew.

Total Number of Possible Inew Images

Our original image I has 2000×2000 = 4,000,000 total pixels. Exactly half (2,000,000) are white, and the other half are black.

Each new image Inew is just a rearrangement of these pixels. This is equivalent to choosing 2,000,000 positions out of 4,000,000 to place the white pixels—since the remaining positions will automatically be black.

The total number of unique Inew images is given by the binomial coefficient:
C(4000000, 2000000)

This is an astronomically large number—way too big to write out explicitly—but it's the exact count of all possible pixel rearrangements that keep the total number of white and black pixels the same as the original image.

Average Euclidean Distance Between I and Inew

First, let's clarify how we calculate Euclidean distance here: treat each image as a vector of pixel values (we'll assign white = 1, black = 0 for simplicity). The Euclidean distance between I and Inew is:
D = sqrt(sum_{i=1 to 4000000} (I_i - Inew_i)^2)

Step 1: Simplify the Squared Distance

Working with the squared distance D² is easier for computing expectations, so let's start there:
D² = sum_{i=1 to 4000000} (I_i - Inew_i)^2

Since I_i and Inew_i are either 0 or 1, (I_i - Inew_i)^2 = I_i + Inew_i - 2I_iInew_i (because x² = x when x is 0 or 1). Summing over all pixels gives us:
D² = sum(I_i) + sum(Inew_i) - 2sum(I_iInew_i)

We know sum(I_i) = 2000000 (original white pixels) and sum(Inew_i) = 2000000 (all Inew images have exactly 2000000 white pixels). Substituting these values in:
D² = 2000000 + 2000000 - 2sum(I_iInew_i) = 4000000 - 2K
where K is the number of positions that are white in both I and Inew (the overlapping white pixels between the original and rearranged image).

Step 2: Expected Value of K

The variable K follows a hypergeometric distribution: we're choosing 2000000 positions (white pixels in Inew) from 4000000 total positions, where 2000000 are "successes" (original white positions). The expected value of K is:
E[K] = (number of white pixels in Inew) * (proportion of original white pixels) = 2000000 * (2000000/4000000) = 1000000

Step 3: Expected Squared Distance

Using linearity of expectation (which holds regardless of distribution), we can compute the expected value of D²:
E[D²] = E[4000000 - 2K] = 4000000 - 2*E[K] = 4000000 - 2*1000000 = 2000000

Step 4: Approximating the Average Euclidean Distance

Since the square root function is concave, Jensen's inequality tells us E[D] ≤ sqrt(E[D²]) = sqrt(2000000) = 1000*sqrt(2) ≈ 1414.21.

For a dataset as large as 4 million pixels, the distribution of K is extremely tightly concentrated around its mean (thanks to the law of large numbers). The variance of K is tiny compared to its mean, so the difference between E[sqrt(D²)] and sqrt(E[D²]) is negligible for all practical purposes.

Thus, the average Euclidean distance between I and all possible Inew images is approximately:
1000√2 ≈ 1414.21

An exact closed-form expression would require evaluating a complex sum of binomial coefficients, but this approximation is essentially perfect given the scale of the problem.


内容的提问来源于stack exchange,提问作者Deepanshu Raju

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.06 22:27:35