寻找C / C ++库计算高斯曲线的使用离散值最大 [英] Looking for C/C++ library calculating max of Gaussian curve using discrete values

查看:267
本文介绍了寻找C / C ++库计算高斯曲线的使用离散值最大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些离散值和假设,这些值位于高斯曲线上。
应该有仅使用3个离散值的最大值,计算的算法。
你知道在C / C ++实现这个计算任何库或code?

I have some discrete values and assumption, that these values lie on a Gaussian curve. There should be an algorithm for max-calculation using only 3 discrete values. Do you know any library or code in C/C++ implementing this calculation?

感谢您!

P.S .:
最初的任务是自动对焦的实现。我移动(显微镜)相机并捕获在不同的位置的图像。最有不同颜色的位置应该有最好的焦点。

P.S.: The original task is auto-focus implementation. I move a (microscope) camera and capture the pictures in different positions. The position having most different colors should have best focus.

修改
这是很久以前的事:-(
I'just想去除这个问题,但离开它尊重很好的答案。

EDIT This was long time ago :-( I'just wanted to remove this question, but left it respecting the good answer.

推荐答案

您有一个应该是高斯曲线上的三个点;这意味着,他们趴在功能:

You have three points that are supposed to be on a Gaussian curve; this means that they lie on the function:

如果你把这个函数的对数,您可以:

If you take the logarithm of this function, you get:

日志高斯函数的

这仅仅是一个简单的2级多项式,即具有simmetry的垂直轴的抛物线:

which is just a simple 2nd grade polynomial, i.e. a parabola with a vertical axis of simmetry:

系数的定义

所以,如果你知道抛物线的三个系数,就可以得出高斯曲线的参数;顺便说一句,高斯函数是一些你感兴趣的唯一参数的的,因为它会告诉你那里的分布中心,即哪里是它的最大值。这立即找出

So, if you know the three coefficients of the parabola, you can derive the parameters of the Gaussian curve; incidentally, the only parameter of the Gaussian function that is of some interest to you is b, since it tells you where the center of the distribution, i.e. where is its maximum. It's immediate to find out that

剩下要做的就是适应抛物线(用原始的X和你的价值观的对数)。现在,如果你有更多的积分,多项式拟合会涉及,但由于你刚才三点,情况非常简单:有一个且只有一个,通过三点去抛物线

All that remains to do is to fit the parabola (with the "original" x and the logarithm of your values). Now, if you had more points, a polynomial fit would be involved, but, since you have just three points, the situation is really simple: there's one and only one parabola that goes through three points.

现在只需要编写抛物线为每个点的方程和解决系统:

You now just have to write the equation of the parabola for each of your points and solve the system:

(用,其中所述的 z来的s为实际值在相应的X读)

(with , where the zs are the actual values read at the corresponding x)

这可以用手(有一些时间)来解决,一些CAS或... <一个href=\"http://stackoverflow.com/questions/717762/how-to-calculate-the-vertex-of-a-parabola-given-three-points/717791#717791\">looking在计算器上的:);因此该解决方案是:

This can be solved by hand (with some time), with some CAS or... looking on StackOverflow :) ; the solution thus is:

因此​​,使用这些过去式(记住:是对的对数的你真正的价值观)和其他关系,你可以很容易地编写一个简单的代数公式让你的高斯曲线的参数b,即它的最大值。

So using these last equations (remember: the ys are the logarithm of your "real" values) and the other relations you can easily write a simple algebraic formula to get the parameter b of your Gaussian curve, i.e. its maximum.

(我可能做了一些乱七八糟的计算,使用效果前,仔细检查他们,总之过程应该是正确的)

(I may have done some mess in the calculations, double-check them before using the results, anyhow the procedure should be correct)

HTTP(感谢://www.$c$ccogs.com/latex/eqneditor.php 为LaTeX的公式)

(thanks at http://www.codecogs.com/latex/eqneditor.php for the LaTeX equations)

这篇关于寻找C / C ++库计算高斯曲线的使用离散值最大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆