template <class DataType1, class DataType2>
double EuclideanDistance(std::vector<DataType1> &inst1, std::vector<DataType2> &inst2) {
  if(inst1.size() != inst2.size()) {
    std::cout<<"the size of the vectors is not the same\n";
    return -1;
  }
  std::vector<double> temp;
  for(size_t i=0; i<inst1.size(); ++i) {
    temp.push_back(pow(inst1.at(i)-inst2.at(i), 2.0));
  }
  double distance=accumulate(temp.begin(), temp.end(), 0.0);
  distance=sqrt(distance);

  return distance;
}

The radial-basis-functions(RBF) technique consists of choosing a function F that has the form

  F(x)=Σwiφ(||x-xi||)

where {φ(||x-xi||)|i=1,2,...,N} is a set of N arbitrary (generally nonlinear) functions, known as

radial-basis functions, and ||•|| denotes a norm that is usually Euclidean.

Much of the theory developed on RBF networks builds on the Gaussian function, an important member

of the class of  radial-basis functions. The Gaussian function may also be viewed as a kernel--hence the

designation of the two-stage procedure based on the Gaussian function as a kernel method.

两个向量之间的欧式距离及radial-basis-functions(RBF)的更多相关文章

  1. 请问两个div之间的上下距离怎么设置

    转自:https://zhidao.baidu.com/question/344630087.html 楼上说的是一种方法,yanzilisan183 <div style="marg ...

  2. MLR:输入两个向量,得出两个向量之间的相关度—Jason niu

    import numpy as np from astropy.units import Ybarn import math from statsmodels.graphics.tukeyplot i ...

  3. 剑指Offer——网易笔试之不要二——欧式距离的典型应用

    剑指Offer--网易笔试之不要二--欧式距离的典型应用 前言 欧几里得度量(euclidean metric)(也称欧氏距离)是一个通常采用的距离定义,指在m维空间中两个点之间的真实距离,或者向量的 ...

  4. 根据地图上的两个点各自的x,y坐标,计算出2点之间的直线距离。显示为公里、米

    /** * calc_map_distance() , 根据地图上的两个点各自的x,y坐标,计算出2点之间的直线距离 * @param array $point_1 第1个点的x,y坐标 array( ...

  5. IOS 计算两个经纬度之间的距离

    IOS 计算两个经纬度之间的距离 一 丶 -(double)distanceBetweenOrderBy:(double) lat1 :(double) lat2 :(double) lng1 :(d ...

  6. 让上下两个DIV块之间有一定距离或没有距离

    1.若想上下DIV块之间距离,只需设定:在CSS里设置DIV标签各属性参数为0div{margin:0;border:0;padding:0;}这里就设置了DIV标签CSS属性相当于初始化了DIV标签 ...

  7. 高德地图 API 计算两个城市之间的距离

    1. 目前在项目中,遇到一个需求不会做,就是要计算两个城市之间的距离,而这两个城市的输入是可变的,如果要使用数据库来先存储两地之间的距离,调用的时候再来调用,那么存数据的时候,要哭的,因为光是省级区域 ...

  8. java如何计算两个经纬度之间的距离?

    /*计算两个经纬度之间的距离 结果单位:米 */public static double getDistance(String lat1Str, String lng1Str, String lat2 ...

  9. AJPFX:求两个城市之间的距离

    键盘录入多个城市: 城市1,城市2,城市3  以 ### 结束输出然后再键盘录入各个城市之间的距离:  格式如下:0,12,4512,0,2245,22,0### 然后按照输入的两个城市,求得两个城市 ...

随机推荐

  1. JS——dom

    节点的获取 <script> var div = document.getElementById("box");//返回指定标签 var div = document. ...

  2. Win32编程笔记

    我都决定了目前不再接触这些个浪费精力的API了,结果为了DirectX编程我特么又回来了.....微软你的东西真是坑人 以前用这玩意的时候需要什么就查,查完就忘了,这次记一记,以后再用也不至于忘的太离 ...

  3. 14、Scala类型参数

    1.泛型类 2.泛型函数 3.上边界Bounds 4.下边界Bounds 5.View Bounds 6.Context Bounds 7.Manifest Context Bounds 8.协变和逆 ...

  4. Centos 安装配置iscsi

    在测试oracle rac的时候用iscsi来模拟磁阵的(真的磁阵需要多路径软件),简单的记录下 #scsi server yum install scsi-target-utils service ...

  5. Ansible 利用playbook批量部署Nginx

    我这里直接部署的,环境已经搭建好,如果不知道的小伙伴可以看上一遍ansible搭建,都写好了,这里是根据前面环境部署的 192.168.30.21     ansible 192.168.30.25  ...

  6. Scrapy实战:使用scrapy再再次爬取干货集中营的妹子图片

    需要学习的知识: 1.获取到的json数据如何处理 2.保存到json文件 3.保存到MongoDB数据库 4.下载项目图片(含缩略图) 1.创建项目 scrapy startproject gank ...

  7. 使用PHP操作MongoDB数据库

    1.连接MongoDB数据库(在已安装php-mongodb扩展的前提下) $config = "mongodb://{$user}:{$pass}@{$host}:{$port}" ...

  8. 2019-02-13 Python爬虫问题 NotImplementedError: Only the following pseudo-classes are implemented: nth-of-type.

    soup=BeautifulSoup(html.text,'lxml') #data=soup.select('body > div.main > div.ctr > div > ...

  9. BZOJ 3732 Network 【模板】kruskal重构树

    [题解] 首先,我们可以发现,A到B的所有路径中,最长边的最小值一定在最小生成树上.我们用Kruskal最小生成树时,假设有两个点集U,V,若加入一条边w(u,v)使U,V联通,那么w就是U中每个点到 ...

  10. 洛谷 P2827 BZOJ 4721 UOJ #264 蚯蚓

    题目描述 本题中,我们将用符号表示对c向下取整,例如:. 蛐蛐国最近蚯蚓成灾了!隔壁跳蚤国的跳蚤也拿蚯蚓们没办法,蛐蛐国王只好去请神刀手来帮他们消灭蚯蚓. 蛐蛐国里现在共有n只蚯蚓(n为正整数).每只 ...