[MatLab] Mahalanobis Distance implement with 3D class using MATLAB
這次直接使用原始資料來實做,
一共有3個class,
每個class有10個sample,
而sample為3維(x1,x2,x3),
test point有4個。
這次直接使用原始資料來實做,
一共有3個class,
每個class有10個sample,
而sample為3維(x1,x2,x3),
test point有4個。
之前以為指標有限制【深度】,
在看過了「指標的藝術」這本書後,
馬上來測試指標深度的極限,
我驗證到10層都還可以編譯,
相信若compiler沒有限制的話,
是可以到【無限】深度的!
不過倒是沒看過有人會寫超過2顆*的程式,
人類的理解程度最多可到3維也就是3顆*,
【空間概念】厲害的人就可以玩弄星星於鼓掌之中XD~
有興趣的人可以玩一玩喔~
/**
Theme: Art of Pointer
Date: 100/01/25
compiler: Dev C++ 4.9.9.2
Author: ShengWen
Blog: https://cg2010studio.wordpress.com/
*/
#include<iostream>
using namespace std;
int main(){
int number=99;
int *onePointer;
int **twoPointer;
int ***threePointer;
int ****fourPointer;
int *****fivePointer;
int ******sixPointer;
int *******sevenPointer;
int ********eightPointer;
int *********ninePointer;
int **********tenPointer;
onePointer=&number;
twoPointer=&onePointer;
threePointer=&twoPointer;
fourPointer=&threePointer;
fivePointer=&fourPointer;
sixPointer=&fivePointer;
sevenPointer=&sixPointer;
eightPointer=&sevenPointer;
ninePointer=&eightPointer;
tenPointer=&ninePointer;
cout<<&tenPointer<<endl;
cout<<tenPointer<<endl;
cout<<*tenPointer<<endl;
cout<<**tenPointer<<endl;
cout<<***tenPointer<<endl;
cout<<****tenPointer<<endl;
cout<<*****tenPointer<<endl;
cout<<******tenPointer<<endl;
cout<<*******tenPointer<<endl;
cout<<********tenPointer<<endl;
cout<<*********tenPointer<<endl;
cout<<**********tenPointer<<endl;
system("pause");
return EXIT_SUCCESS;
}
輸出結果:
0x23ff4c
0x23ff50
0x23ff54
0x23ff58
0x23ff5c
0x23ff60
0x23ff64
0x23ff68
0x23ff6c
0x23ff70
0x23ff74
99
請按任意鍵繼續 . . .
總算知道【馬氏距離】的意義,
加上實際操作MATLAB來驗證理論,
真正瞭然於心。
話說MATLAB真是一個強大的工具呢!
Mahalanobis distance
From WiKi (http://en.wikipedia.org/wiki/Mahalanobis_distance)
In statistics, Mahalanobis distance is a distance measure introduced by P. C. Mahalanobis in 1936. It is based on correlations between variables by which different patterns can be identified and analyzed. It is a useful way of determining similarity of an unknown sample set to a known one. It differs from Euclidean distance in that it takes into account the correlations of the data set and is scale-invariant. In other words, it is a multivariate effect size.
Definition
Formally, the Mahalanobis distance of a multivariate vector
from a group of values with mean
and covariance matrix S is defined as:![]()
有時候寫程式會用到亂數,
而且產生得亂數不會重複。
我用的方法是【撲克牌】法,
也就是1-52本來就已經決定,
接著兩兩對調,
對調的次數越多,
亂數的序列越均勻,
最後再從52張牌抽一張,
那個就是【撲克牌】法所產生的亂數。
有關透視投影的概念,簡單來說就是同樣的物體,放在離眼睛較近的地方,物體成像看起來比較大,若放在離眼睛較遠的地方,物體成像看起來就比較小。在畫家手中的透視投影還有分一點、兩點、三點透視,這部份可參考:透視投影 (Perspective Projection)。
HappyMan・迴響