Пример #1
0
int main()
{
    MSS_BEGIN(int, main);

    typedef gubg::math::distribution::Kernel<double, double> Kernel;
    Kernel kernel;
    vector<double> data({1.0, 2.0, 2.5});
    kernel.learn(data);
    L(kernel.density(0.0));
    L(kernel.density(1.0));

    MSS_END();
}
Пример #2
0
                    double l1Distance(const Kernel &rhs, long nr = 1000)
                    {
                        double a,b,x;
                        a = min_ - 4.0*width_;
                        b = rhs.min_ - 4.0*rhs.width_;
                        double dm = (a < b ? a : b);
                        a = max_ + 4.0*width_;
                        b = rhs.max_ + 4.0*rhs.width_;
                        double dM = (a > b ? a : b);
                        double dD=(dM-dm)/(nr-1);
                        const function::Linear<double> lt(0, dm, nr-1, dM);

                        dM = 0.0;
                        for (long i=0; i<nr; ++i)
                        {
                            x = lt(i);
                            dM += fabs(density(x)-rhs.density(x))*dD;
                        }
                        return dM;
                    }