Stats

Popular Posts

Followers

Matehmatica 教學 Fisher Canonical Discriminant Analysis

戴忠淵 於 2011年12月7日星期三 下午4:02 發表

Fisher Canonical Discriminant Analysis


myline[x0_,y0_]:=
Line[{{x0,y0},{x,(-c-a*x)/b}/.
x->(b^2x0-a(c+b*y0))/(a^2+b^2)}]

data={RandomReal[
MultinormalDistribution[{1,1},{{2,1/2},{1/2,1}}],100],
RandomReal[MultinormalDistribution[{8,8},{{2,1/2},{1/2,1}}],100],
RandomReal[MultinormalDistribution[{3,8},{{2,1/2},{1/2,1}}],100]
};

Manipulate[
Block[{pts={point1,point2},a,b,c,m},
m=(pts[[2,2]]-pts[[1,2]])/(pts[[2,1]]-pts[[1,1]]);
b=-1;a=m;c=-m*pts[[1,1]]+pts[[1,2]];
Grid[{{a*x+b*y+c},
{ContourPlot[a*x+b*y+c==0,{x,-10,20},{y,-10,20},
ImageSize->350,
Epilog->{Red,Point@data[[1]],
Evaluate[myline@@@data[[1]]],
Green,Point@data[[2]],Evaluate[myline@@@data[[2]]],
Brown,Point@data[[3]],Evaluate[myline@@@data[[3]]]}
]}
}]
],{{point1,{-5,5}},Locator},{{point2,{15,15}},Locator}]
Tags:

讀者回應 ( 0 意見 )

發佈留言

Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.

如果這篇文章對你有幫助,那請留個訊息給我~