image thumbnail

SLM - Shape Language Modeling

最小二乘样条模型使用形状原语

25.7k下载

Updated16 Apr 2017

查看许可证

If you could only download one curve fitting tool to your laptop on a desert island, this should be it.
For many years I have recommended that people use least squares splines for their curve fits, with a caveat. Splines offer tremendous flexibility to build a curve in any shape or form. They can nicely fit almost any set of data you will throw at them. This same flexibility is their downfall at times too. Like polynomial models, splines can be too flexible if you are not careful. The trick is to bring your knowledge of the system under study to the problem.
作为科学家,工程师,数据分析师等,您经常了解要建模的过程。有时,这些知识来自物理原理,有时是由于经验而产生的,有时知识只是从查看数据图。无论消息来源如何,我们通常都希望在我们的建模工作中建立对过程的先验知识。这也许是使用非线性回归工具的最大原因,我会说是最糟糕的原因。如果您仅将Sigmoid函数拟合到数据中,因为它恰好是单调,并且您的数据似乎具有该属性,那么您选择了错误的建模工具。(如果您要安装Sigmoid,因为这是您过程的合适模型,请继续并安装Sigmoid。)
I'll argue the proper tool when you merely need a monotonic curve fit is a least squares spline, but a spline that is properly constrained to have the fundamental shape you know to be there. This is a very Bayesian approach to modeling, and a very useful one in my experience.
此处提供的SLM工具为您提供了易于使用的接口来从数据中构建无限数量的曲线类型。SLM代表形状语言建模。这个想法是要使用一组形状原始素为曲线拟合提供处方。如果您的曲线是单调的,则将这些信息构建到模型中,因此您可以估算最适合您数据的单调曲线。您会发现的是,一旦您采用了适当的约束,您会想知道为什么您过去曾经使用过非线性回归!!!
For example, the screenshot for this file was generated for the following data:

x = (sort(rand(1,100)) - 0.5)*pi;
y = sin(x).^5 + randn(size(x))/10;

SLM =slmengine(x,y,'plot','on','knots',10,'increasing','on', ...
'leftslope',0,'rightslope',0)
SLM =
表格:'SLM'
学位:3
结: [10x1 double]
COEF:[10x2 double]
处方:[1x1结构]
x: [100x1 double]
Y:[100x1 double]

You can evaluate the spline or its derivatives using slmeval.

slmeval(1.3,slm)
ans =
0.79491

You plot these splines using plotslm.

绘图(SLM)

绘图函数很不错,因为它是一个简单的GUI,允许您绘制曲线,残差,其衍生物或积分。您还可以评估样条的各种参数,例如在间隔,最小或最大斜率等上的最大函数值等。

slmpar(slm,'maxslope')
ans =
1.5481

您可以使用属性/价值对接口向Slmengine提供所有这些信息。SLMSET介导了这种交互,因此您可以使用它来创建将要使用的属性集。默认的属性集及其值由SLMSET给出。关于您功能的形状,斜率,曲率,值等的所有内容都可以通过简单的命令来控制。Slmengine还提供了生成各种订单的花纹以及免费结的能力。

有关正在使用的SLM工具的完整示例,请参见随附的提交的包含已发布的教程。曲线拟合的形状语言建模概念中还包含了一篇小论文。

The SLM toolkit will be considerably improved at some time in the future. I will add a graphical interface. As well, if I have missed any natural shape primitives, please let me know. While I have tried to be very inclusive, surely there is something I've missed. If I can add your favorite to the list above I will try to do so.

Finally, the SLM tools require the optimization toolbox to solve the various estimation problems.

引用为

约翰·德·埃里科(John D'Errico)(2022)。SLM - Shape Language Modeling(//www.tianjin-qmedu.com/matlabcentral/fileexchange/24443-slm-shape-language-modeling),matlab中央文件交换。检索

slmtools/html/