スキップしてメイン コンテンツに移動

マハラノビス距離

Introduction


今日はマハラノビス距離について書いていきます。
マハラノビス距離はそれぞれの次元に相関があるときに有効とされています。
ある特徴と特徴に相関があることは往々にしてあると思います。
この距離は距離の公理を満たします。
また、統計学において大事な距離関数になります。
もし、統計や機械学習に興味がおありでしたらぜひこのブログをご覧ください。

概要

  • 距離の公理
  • マンハッタン距離の定義
  • マンハッタン距離のイメージ

距離の公理

もし、dが距離関数であるならば、dは次を満たします。
\(d:X \times X -> R\)
  • \(d(x,y) \geq 0\)
  • \(d(x,y) = 0 \leftrightarrow x = y\)
  • \(d(x,y) = d(y,x)\)
  • \(d(x,z) \leq d(x,y) + d(y,z)\)

マハラノビス距離

マハラノビス距離は距離関数です。
次のように定義されます。
\[D_{M}(x) = \sqrt{(x-\mu)^T \Sigma^{-1} (x-\mu)}\]
ここで、 \(\mu\) is mean vector
\[\mu = (\mu_1,\mu_2,....,\mu_n)\]
さらに \(\Sigma\) は共分散行列です。
xとyのマハラノビス距離は
\begin{eqnarray*} d(x,y) &=& \sqrt{(x-\mu-(y-\mu)^T \Sigma^{-1} (x-\mu-(y-\mu)}\\ &=& \sqrt{(x-y)^T \Sigma^{-1} (x-y)} \end{eqnarray*}です。

マハラノビス距離のイメージ

初めに、ユークリッド距離を見てみましょう。
\[d(x,y) = \sqrt{<x^T,y>}\]
ユークリッド距離は \(x\) and \(y\) がもし、ある円の上にあるのなら、同じ距離としてみます。
enter image description here
これはデータが円状に分布しているときに有効になります。
enter image description here
しかし、データが楕円上に分布しているときは、ユークリッド距離は有効ではありません。
enter image description here
なぜなら、上のXとYを同じ距離だと見たいからです。
マハラノビス距離はXとYが同じ楕円の上のある時に等距離とみなします。
enter image description here
距離は機械学習でよく登場します。距離関数をマハラノビス距離を使うことでなにか面白い結果が得られるかもしれません。

コメント

このブログの人気の投稿

離散フーリエ変換

Introduction English ver 今日は離散フーリエ変換について書きます。 現在、シグナル解析についてのpdfを作成中です。このpdfは github で公開中です。 シグナル解析は、courseraのレクチャーで勉強中です。 ここ にリンクを貼っておきます。 pdfは随時更新中です。

heap structure

Introduction 日本語 ver Today, I will write about heap structure. The heap structure is one of the data structure. My reason of studying heap structure is that I joined seminar of Ritsumeikan Univ. I used this  slide  in seminar of Ritsumeikan Univ. Overview data structure binary tree heap Implementation heap sort Data structure I will explain about data structure before explaining about heap. Data structure is how to keep data. Data structure is selected on the basis of operation which you want to.  Heap belong to data structure called priority queue. priority queue have purpose which  add data pick up minimum data (and remove)  Binary Tree Let, E and V are sets. The element $e \in E$ is called edge. The element $v \in V$ is called node. g:E->V×V is map to V × V from E. (E,V,g) is called graph. For example, The arrows are edge. The circles are node. This is expressed map. It is possible to go to node 3 from 1....

LIMIT and user variable in MysQL

Problem 日本語 ver I want to use this query in PROCEDURE. SET @user_variable = FLOOR(RAND()*10); INSERT INTO  Table_name (columns_name) VALUES (1) FROM Table_name ORDER BY RAND() LIMIT 1 OFFSET @user_variable; This query want to substitute 1 for the @user_variable 'th line of columns_name, but this query does not work. A cause is that LIMIT and OFFSET does not user variable. Solution SET @user_variable = FLOOR(RAND()*10); PREPARE SET_STMT FROM 'INSERT INTO  Table_name (columns_name) VALUES (1) FROM Table_name ORDER BY RAND() LIMIT 1 OFFSET ?;';  EXECUTE SET_STMT USING @user_variable; Conclusion, if you want to use user variable with LIMIT or OFFSET, use PREPARE STATMENT. Reference http://techtipshoge.blogspot.com/2011/10/limit.html