问题描述
我正在做一个插入样本数据{(x_i,y_i)}
的项目,其中x_i
的输入域位于4D空间并输出y_i
位于 3D 空间.我需要为两个方向生成两个查找表.我设法生成了 4D ->3D
表.但是 3D ->4D
一个是棘手的.样本数据不在规则的网格点上,也不是一对一的映射.有没有已知的方法来治疗这种情况?我在网上做了一些搜索,但我发现的只是 3D ->3D
映射,不适合这种情况.谢谢!
I am working on a project of interpolating sample data {(x_i,y_i)}
where the input domain for x_i
locates in 4D space and output y_i
locates in 3D space. I need generate two look up tables for both directions. I managed to generate the 4D -> 3D
table. But the 3D -> 4D
one is tricky. The sample data are not on regular grid points, and it is not one to one mapping. Is there any known method to treat this situation? I did some search online, but what I found is only for 3D -> 3D
mapping, which are not suitable for this case. Thank you!
回答 Spektre 的问题:
To answer the questions of Spektre:
X(3D) ->Y(4D)
就是这种情况 1X ->nY
我想生成一个表,对于任何给定的 X
,我们都可以找到 Y
的值.样本数据没有占据X
的所有域.但是没关系,我们只需要样本数据域内的点的准确性.例如,我们有像 {(x1,x2,x3) ->(y1,y2,y3,y4)}
这样的样本数据.可能我们还有一个样本数据 {(x1,x2,x3) ->(y1_1,y2_1,y3_1,y4_1)}
.但是没关系.我们需要一个空间X
中任意(a,b,c)
的表格,它对应一个(e,f,g,h)
在空格 Y
中.可能有不止一种选择,但我们只需要一种.(对不起,如果有符号混淆)
I want to generate a table that for any given X
, we can find the value for Y
. The sample data is not occupy all the domain of X
. But it's fine, we only need accuracy for point inside the domain of sample data. For example, we have sample data like {(x1,x2,x3) ->(y1,y2,y3,y4)}
. It is possible we also have a sample data {(x1,x2,x3) -> (y1_1,y2_1,y3_1,y4_1)}
. But it is OK. We need a table for any (a,b,c)
in space X
, it corresponds to ONE (e,f,g,h)
in space Y
. There might be more than one choice, but we only need one. (Sorry for the symbol confusing if any)
一种可能的处理方法:由于我已经建立了从Y->X
的平滑映射,我可以使用牛顿法或任何其他方法来反向搜索点y
对于任何给定的 x
.但它不够准确,而且耗时.因为我需要对表中的每个点都做搜索,误差是模型误差与搜索误差之和.
One possible way to deal with this: Since I have already established a smooth mapping from Y->X
, I can use Newton's method or any other method to reverse search the point y
for any given x
. But it is not accurate enough, and time consuming. Because I need do search for each point in the table, and the error is the sum of the model error with the search error.
所以我想知道可以直接找到一个映射来插入样本数据,而不是在 3 中进行这种搜索.
So I want to know it is possible to find a mapping directly to interpolate the sample data instead of doing such kind of search in 3.
推荐答案
您正在寻找投影/映射
正如你提到的,你有投影 X(3D) ->Y(4D)
在你的情况下不是一对一的,那么它是 (1 X -> n Y)
还是 (n X -> 1 Y)
或 (n X -> m Y)
?
as you mentioned you have projection X(3D) -> Y(4D)
which is not one to one in your case so what case it is (1 X -> n Y)
or (n X -> 1 Y)
or (n X -> m Y)
?
您要使用查找表
我假设您只想为给定的 Y
生成所有 X
非 (1 to 1)
映射的问题是您可以仅当有查找表时才使用查找表
I assume you just want to generate all X
for given Y
the problem with non (1 to 1)
mappings is that you can use lookup table only if it has
- 所有有效点
- 或映射具有某种几何或数学对称性(例如
X
和Y
空间中的点之间的距离相似,并且映射是连续的)
- all valid points
- or mapping has some geometric or mathematic symmetry (for example distance between points in
X
andY
space is similar,and mapping is continuous)
您无法在通用映射点之间进行插值,所以问题是您想到的是哪种映射/投影?
You can not interpolate between generic mapped points so the question is what kind of mapping/projection you have in mind?
首先是 1->1 投影/映射插值
如果您的
X->Y
投影映射适合插值
if your
X->Y
projection mapping is suitable for interpolation
然后对于 3D->4D
使用 tri-linear 插值.找到最近的 8
个点(每个点在其轴上形成网格超立方体)并在所有 4
维
then for 3D->4D
use tri-linear interpolation. Find closest 8
points (each in its axis to form grid hypercube) and interpolate between them in all 4
dimensions
如果您的 X 投影映射适合插值
if your X<-Y
projection mapping is suitable for interpolation
然后对于 4D->3D
使用 quatro-linear 插值.找到最近的 16
个点(每个点都在其轴上形成网格超立方体)并在所有 3
维度上在它们之间进行插值.
then for 4D->3D
use quatro-linear interpolation. Find closest 16
points (each in its axis to form grid hypercube) and interpolate between them in all 3
dimensions.
现在 1->n
或 n->m
投影/映射
Now what about 1->n
or n->m
projections/mappings
这完全取决于我一无所知的投影/映射属性.尝试提供数据集示例,最好添加一些图像.
That solely depends on the projection/mapping properties which I know nothing of. Try to provide an example of your datasets and adding some image would be best.
[edit1] 1 X
我仍然会使用quatro-linear 插值.您仍然需要搜索您的 Y
表,但如果您将其分组为 4D
网格,那么它应该很容易.
I still would use quatro-linear interpolation. You still will need to search your Y
table but if you group it like 4D
grid then it should be easy enough.
在
Y
-table 中找到16
个最接近输入Y
点的点
find
16
closest points inY
-table to your inputY
point
这些点应该是所有轴的每个 +/-
方向上最接近您的 Y
的点.在 3D 中,它看起来像这样:
These points should be the closest points to your Y
in each +/-
direction of all axises. In 3D it looks like this:
- 红点是你的输入
Y
点 - 蓝色点是找到的最近点(网格),它们不需要像图像上那样对称.
请不要让我绘制有意义的 4D
示例:)(至少对于清醒的头脑)
Please do not want me to draw 4D
example that make sense :) (at least for sober mind)
插值
找到对应的X
点.如果每个点有多个然后选择一个与其他点更接近的点......现在你应该有 16 X
点和 16+1 Y
点.然后从 Y
点开始,您只需要计算从输入 Y
点沿线的距离.这些距离用作线性插值的参数.将它们规范化为 where
find corresponding X
points. If there is more then one per point chose the closer one to the others ... Now you should have 16 X
points and 16+1 Y
points. Then from Y
points you need just to calculate the distance along lines from your input Y
point. These distances are used as parameter for linear interpolations. Normalize them to <0,1>
where
- 0 表示左"点,1 表示右"点
- 0.5 表示正中
您将需要在每个 Y
域维度中的标量距离.现在只需计算沿线性插值的所有 X
点,直到在 X
域中得到相应的红点.
You will need this scalar distance in each of Y
-domain dimension. Now just compute all the X
points along the linear interpolations until you get the corresponding red point in X
-domain.
使用三线性插值(3D
)有4+2+1=7
线性插值(如图像).对于quatro-linear 插值(4D
),有8+4+2+1=15
线性插值.
With tri-linear interpolation (3D
) there are 4+2+1=7
linear interpolations (as on image). For quatro-linear interpolation (4D
) there are 8+4+2+1=15
linear interpolations.
线性插值
X = X0 + (X1-X0)*t
X
为插值点X0,X1
分别是左"、右"点t
是距离参数X
is interpolated pointX0,X1
are the 'left','right' pointst
is the distance parameter<0,1>
这篇关于多维网格的逆插值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!