poster
2019-12-10, 20:30
假设我有一些数据,我想为其拟合参数化模型。我的目标是为此模型参数找到最佳值。
我正在使用AIC (http://en.wikipedia.org/wiki/Akaike_information_criterion) / BIC (http://en.wikipedia.org/wiki/Bayesian_information_criterion) / MDL (http://en.wikipedia.org/wiki/Minimum_description_length)类型的标准进行模型选择,该标准奖励具有低误差的模型,但也惩罚具有高复杂性的模型(可以说,我们正在寻找这种数据的最简单但最有说服力的解释,也就是说,la Occam的剃刀 (http://en.wikipedia.org/wiki/Occam%27s_Razor) )。
在上面的内容之后,这是我针对三种不同条件得到的东西的一个示例(其中两个要最小化,一个要最大化):
https://i.stack.imgur.com/iBgo3.pnghttps://i.stack.imgur.com/AG52Y.png
在视觉上,您可以轻松看到弯头形状,并且可以在该区域中的某个位置选择参数值。问题是我正在做大量实验,因此我需要一种无需干预即可找到该值的方法。
我的第一个直觉是尝试从拐角处以45度角绘制一条线,并一直移动它直到与曲线相交,但这说起来容易做起来难:)如果曲线有些偏斜,它也可能会错过感兴趣的区域。
关于如何实施此想法或更好的想法?
这是重现以上图之一所需的样本:
curve = [8.4663 8.3457 5.4507 5.3275 4.8305 4.7895 4.6889 4.6833 4.6819 4.6542 4.6501 4.6287 4.6162 4.585 4.5535 4.5134 4.474 4.4089 4.3797 4.3494 4.3268 4.3218 4.3206 4.3206 4.3203 4.2975 4.2864 4.2821 4.2544 4.2288 4.2281 4.2265 4.2226 4.2206 4.2146 4.2144 4.2114 4.1923 4.19 4.1894 4.1785 4.178 4.1694 4.1694 4.1694 4.1556 4.1498 4.1498 4.1357 4.1222 4.1222 4.1217 4.1192 4.1178 4.1139 4.1135 4.1125 4.1035 4.1025 4.1023 4.0971 4.0969 4.0915 4.0915 4.0914 4.0836 4.0804 4.0803 4.0722 4.065 4.065 4.0649 4.0644 4.0637 4.0616 4.0616 4.061 4.0572 4.0563 4.056 4.0545 4.0545 4.0522 4.0519 4.0514 4.0484 4.0467 4.0463 4.0422 4.0392 4.0388 4.0385 4.0385 4.0383 4.038 4.0379 4.0375 4.0364 4.0353 4.0344]; plot(1:100, curve) 编辑
我接受了乔纳斯 (https://stackoverflow.com/questions/2018178/finding-the-best-trade-off-point-on-a-curve/2022348#2022348)给出的解决方案。基本上,对于曲线上的每个点p ,我们找到一个最大距离为d的点:
https://i.stack.imgur.com/IoRbN.png
回答:
查找弯头的快速方法是从曲线的第一点到最后一条点画一条线,然后找到距离该线最远的数据点。
当然,这在某种程度上取决于您在该行的平坦部分中拥有的点数,但是如果您每次都测试相同数量的参数,那么应该可以得出结论。
curve = [8.4663 8.3457 5.4507 5.3275 4.8305 4.7895 4.6889 4.6833 4.6819 4.6542 4.6501 4.6287 4.6162 4.585 4.5535 4.5134 4.474 4.4089 4.3797 4.3494 4.3268 4.3218 4.3206 4.3206 4.3203 4.2975 4.2864 4.2821 4.2544 4.2288 4.2281 4.2265 4.2226 4.2206 4.2146 4.2144 4.2114 4.1923 4.19 4.1894 4.1785 4.178 4.1694 4.1694 4.1694 4.1556 4.1498 4.1498 4.1357 4.1222 4.1222 4.1217 4.1192 4.1178 4.1139 4.1135 4.1125 4.1035 4.1025 4.1023 4.0971 4.0969 4.0915 4.0915 4.0914 4.0836 4.0804 4.0803 4.0722 4.065 4.065 4.0649 4.0644 4.0637 4.0616 4.0616 4.061 4.0572 4.0563 4.056 4.0545 4.0545 4.0522 4.0519 4.0514 4.0484 4.0467 4.0463 4.0422 4.0392 4.0388 4.0385 4.0385 4.0383 4.038 4.0379 4.0375 4.0364 4.0353 4.0344]; %# get coordinates of all the points nPoints = length(curve); allCoord = [1:nPoints;curve]'; %'# SO formatting %# pull out first point firstPoint = allCoord(1,:); %# get vector between first and last point - this is the line lineVec = allCoord(end,:) - firstPoint; %# normalize the line vector lineVecN = lineVec / sqrt(sum(lineVec.^2)); %# find the distance from each point to the line: %# vector between all points and first point vecFromFirst = bsxfun(@minus, allCoord, firstPoint); %# To calculate the distance to the line, we split vecFromFirst into two %# components, one that is parallel to the line and one that is perpendicular %# Then, we take the norm of the part that is perpendicular to the line and %# get the distance. %# We find the vector parallel to the line by projecting vecFromFirst onto %# the line. The perpendicular vector is vecFromFirst - vecFromFirstParallel %# We project vecFromFirst by taking the scalar product of the vector with %# the unit vector that points in the direction of the line (this gives us %# the length of the projection of vecFromFirst onto the line). If we %# multiply the scalar product by the unit vector, we have vecFromFirstParallel scalarProduct = dot(vecFromFirst, repmat(lineVecN,nPoints,1), 2); vecFromFirstParallel = scalarProduct * lineVecN; vecToLine = vecFromFirst - vecFromFirstParallel; %# distance to line is the norm of vecToLine distToLine = sqrt(sum(vecToLine.^2,2)); %# plot the distance to the line figure('Name','distance from curve to line'), plot(distToLine) %# now all you need is to find the maximum [maxDist,idxOfBestPoint] = max(distToLine); %# plot figure, plot(curve) hold on plot(allCoord(idxOfBestPoint,1), allCoord(idxOfBestPoint,2), 'or')
更多&回答... (https://stackoverflow.com/questions/2018178)
我正在使用AIC (http://en.wikipedia.org/wiki/Akaike_information_criterion) / BIC (http://en.wikipedia.org/wiki/Bayesian_information_criterion) / MDL (http://en.wikipedia.org/wiki/Minimum_description_length)类型的标准进行模型选择,该标准奖励具有低误差的模型,但也惩罚具有高复杂性的模型(可以说,我们正在寻找这种数据的最简单但最有说服力的解释,也就是说,la Occam的剃刀 (http://en.wikipedia.org/wiki/Occam%27s_Razor) )。
在上面的内容之后,这是我针对三种不同条件得到的东西的一个示例(其中两个要最小化,一个要最大化):
https://i.stack.imgur.com/iBgo3.pnghttps://i.stack.imgur.com/AG52Y.png
在视觉上,您可以轻松看到弯头形状,并且可以在该区域中的某个位置选择参数值。问题是我正在做大量实验,因此我需要一种无需干预即可找到该值的方法。
我的第一个直觉是尝试从拐角处以45度角绘制一条线,并一直移动它直到与曲线相交,但这说起来容易做起来难:)如果曲线有些偏斜,它也可能会错过感兴趣的区域。
关于如何实施此想法或更好的想法?
这是重现以上图之一所需的样本:
curve = [8.4663 8.3457 5.4507 5.3275 4.8305 4.7895 4.6889 4.6833 4.6819 4.6542 4.6501 4.6287 4.6162 4.585 4.5535 4.5134 4.474 4.4089 4.3797 4.3494 4.3268 4.3218 4.3206 4.3206 4.3203 4.2975 4.2864 4.2821 4.2544 4.2288 4.2281 4.2265 4.2226 4.2206 4.2146 4.2144 4.2114 4.1923 4.19 4.1894 4.1785 4.178 4.1694 4.1694 4.1694 4.1556 4.1498 4.1498 4.1357 4.1222 4.1222 4.1217 4.1192 4.1178 4.1139 4.1135 4.1125 4.1035 4.1025 4.1023 4.0971 4.0969 4.0915 4.0915 4.0914 4.0836 4.0804 4.0803 4.0722 4.065 4.065 4.0649 4.0644 4.0637 4.0616 4.0616 4.061 4.0572 4.0563 4.056 4.0545 4.0545 4.0522 4.0519 4.0514 4.0484 4.0467 4.0463 4.0422 4.0392 4.0388 4.0385 4.0385 4.0383 4.038 4.0379 4.0375 4.0364 4.0353 4.0344]; plot(1:100, curve) 编辑
我接受了乔纳斯 (https://stackoverflow.com/questions/2018178/finding-the-best-trade-off-point-on-a-curve/2022348#2022348)给出的解决方案。基本上,对于曲线上的每个点p ,我们找到一个最大距离为d的点:
https://i.stack.imgur.com/IoRbN.png
回答:
查找弯头的快速方法是从曲线的第一点到最后一条点画一条线,然后找到距离该线最远的数据点。
当然,这在某种程度上取决于您在该行的平坦部分中拥有的点数,但是如果您每次都测试相同数量的参数,那么应该可以得出结论。
curve = [8.4663 8.3457 5.4507 5.3275 4.8305 4.7895 4.6889 4.6833 4.6819 4.6542 4.6501 4.6287 4.6162 4.585 4.5535 4.5134 4.474 4.4089 4.3797 4.3494 4.3268 4.3218 4.3206 4.3206 4.3203 4.2975 4.2864 4.2821 4.2544 4.2288 4.2281 4.2265 4.2226 4.2206 4.2146 4.2144 4.2114 4.1923 4.19 4.1894 4.1785 4.178 4.1694 4.1694 4.1694 4.1556 4.1498 4.1498 4.1357 4.1222 4.1222 4.1217 4.1192 4.1178 4.1139 4.1135 4.1125 4.1035 4.1025 4.1023 4.0971 4.0969 4.0915 4.0915 4.0914 4.0836 4.0804 4.0803 4.0722 4.065 4.065 4.0649 4.0644 4.0637 4.0616 4.0616 4.061 4.0572 4.0563 4.056 4.0545 4.0545 4.0522 4.0519 4.0514 4.0484 4.0467 4.0463 4.0422 4.0392 4.0388 4.0385 4.0385 4.0383 4.038 4.0379 4.0375 4.0364 4.0353 4.0344]; %# get coordinates of all the points nPoints = length(curve); allCoord = [1:nPoints;curve]'; %'# SO formatting %# pull out first point firstPoint = allCoord(1,:); %# get vector between first and last point - this is the line lineVec = allCoord(end,:) - firstPoint; %# normalize the line vector lineVecN = lineVec / sqrt(sum(lineVec.^2)); %# find the distance from each point to the line: %# vector between all points and first point vecFromFirst = bsxfun(@minus, allCoord, firstPoint); %# To calculate the distance to the line, we split vecFromFirst into two %# components, one that is parallel to the line and one that is perpendicular %# Then, we take the norm of the part that is perpendicular to the line and %# get the distance. %# We find the vector parallel to the line by projecting vecFromFirst onto %# the line. The perpendicular vector is vecFromFirst - vecFromFirstParallel %# We project vecFromFirst by taking the scalar product of the vector with %# the unit vector that points in the direction of the line (this gives us %# the length of the projection of vecFromFirst onto the line). If we %# multiply the scalar product by the unit vector, we have vecFromFirstParallel scalarProduct = dot(vecFromFirst, repmat(lineVecN,nPoints,1), 2); vecFromFirstParallel = scalarProduct * lineVecN; vecToLine = vecFromFirst - vecFromFirstParallel; %# distance to line is the norm of vecToLine distToLine = sqrt(sum(vecToLine.^2,2)); %# plot the distance to the line figure('Name','distance from curve to line'), plot(distToLine) %# now all you need is to find the maximum [maxDist,idxOfBestPoint] = max(distToLine); %# plot figure, plot(curve) hold on plot(allCoord(idxOfBestPoint,1), allCoord(idxOfBestPoint,2), 'or')
更多&回答... (https://stackoverflow.com/questions/2018178)