コンテンツにスキップ

ファイル:Em old faithful.gif

ページのコンテンツが他言語でサポートされていません。

Em_old_faithful.gif(360 × 360 ピクセル、ファイルサイズ: 272キロバイト、MIME タイプ: image/gif、ループします、30 フレーム、6.0秒)

概要

解説 An animation of the EM algorithm to a 2 component Gaussian mixture model on the Old Faithful dataset
日付
原典 投稿者自身による著作物
作者 3mta3 (talk) 16:55, 23 March 2009 (UTC)

Created in R with code below (released under same license as image), combined into animated gif using ImageMagick.

There should be a way to make this file smaller (e.g. using less colours or an animated PNG). If you can, feel free to upload a new copy.

#load library for multivariate normal
library(mvtnorm)
#load Old Faithful data frame
data(faithful)

#setup grid for plotting
xpts <- seq(from=1,to=6,length.out=100)
ypts <- seq(from=40,to=100,length.out=100)

#initial parameter estimates (chosen to be deliberately bad)
theta <- list(
             tau=c(0.5,0.5),
             mu1=c(2.8,75),
             mu2=c(3.6,58),
             sigma1=matrix(c(0.8,7,7,70),ncol=2),
             sigma2=matrix(c(0.8,7,7,70),ncol=2)
             )

#E step: calculates conditional probabilities for latent variables
E.step <- function(theta)
 t(apply(cbind(
     theta$tau[1] * dmvnorm(faithful,mean=theta$mu1,sigma=theta$sigma1),
     theta$tau[2] * dmvnorm(faithful,mean=theta$mu2,sigma=theta$sigma2)
     ),1,function(x) x/sum(x)))
#M step: calculates the parameter estimates which maximise Q
M.step <- function(T) list(
 tau= apply(T,2,mean),
 mu1= apply(faithful,2,weighted.mean,T[,1]),
 mu2= apply(faithful,2,weighted.mean,T[,2]),
 sigma1= cov.wt(faithful,T[,1])$cov,
 sigma2= cov.wt(faithful,T[,2])$cov)

#function to plot current data
plot.em <- function(theta){
 mixture.contour <- outer(xpts,ypts,function(x,y) {
   theta$tau[1]*dmvnorm(cbind(x,y),mean=theta$mu1,sigma=theta$sigma1) + theta$tau[2]*dmvnorm(cbind(x,y),mean=theta$mu2,sigma=theta$sigma2)
   })
 contour(xpts,ypts,mixture.contour,nlevels=5,drawlabel=FALSE,col="red",xlab="Eruption time (mins)",ylab="Waiting time (mins)",main="Waiting time vs Eruption time of the Old Faithful geyser")
 points(faithful)
}

#plot initial contours
iter <- 1
png(filename=paste("em",formatC(iter,width=4,flag="0"),".png",sep=""))
plot.em(theta)
dev.off()

#run EM and plot
for (iter in 2:30){
 T <- E.step(theta)
 theta <- M.step(T)
 png(filename=paste("em",formatC(iter,width=4,flag="0"),".png",sep=""))
 plot.em(theta)
 dev.off()
}

ライセンス

この作品の著作権者である私は、この作品を以下のライセンスで提供します。
w:ja:クリエイティブ・コモンズ
表示 継承
このファイルはクリエイティブ・コモンズ 表示-継承 3.0 非移植ライセンスのもとに利用を許諾されています。
あなたは以下の条件に従う場合に限り、自由に
  • 共有 – 本作品を複製、頒布、展示、実演できます。
  • 再構成 – 二次的著作物を作成できます。
あなたの従うべき条件は以下の通りです。
  • 表示 – あなたは適切なクレジットを表示し、ライセンスへのリンクを提供し、変更があったらその旨を示さなければなりません。これらは合理的であればどのような方法で行っても構いませんが、許諾者があなたやあなたの利用行為を支持していると示唆するような方法は除きます。
  • 継承 – もしあなたがこの作品をリミックスしたり、改変したり、加工した場合には、あなたはあなたの貢献部分を元の作品とこれと同一または互換性があるライセンスの下に頒布しなければなりません。
GNU head この文書は、フリーソフトウェア財団発行のGNUフリー文書利用許諾書 (GNU Free Documentation License) 1.2またはそれ以降のバージョンの規約に基づき、複製や再配布、改変が許可されます。不可変更部分、表紙、背表紙はありません。このライセンスの複製は、GNUフリー文書利用許諾書という章に含まれています。
あなたは上記のライセンスから、どれか一つ以上を選択できます。
 
この 統計図表Rで作成されました。

キャプション

このファイルの内容を1行で記述してください

このファイルに描写されている項目

題材

23 3 2009

ファイルの履歴

過去の版のファイルを表示するには、その版の日時をクリックしてください。

日付と時刻サムネイル寸法利用者コメント
現在の版2009年3月23日 (月) 17:102009年3月23日 (月) 17:10時点における版のサムネイル360 × 360 (272キロバイト)3mta3A bit smaller
2009年3月23日 (月) 16:552009年3月23日 (月) 16:55時点における版のサムネイル480 × 480 (365キロバイト)3mta3{{Information |Description=An animation of the EM algorithm to a 2 component Gaussian mixture model on the [http://stat.ethz.ch/R-manual/R-patched/library/datasets/html/faithful.html Old Faithful dataset] |Source=self-made |Date=2009-03-23 |Author= ~~~~ |

以下の​ 2 ページがこのファイルを使用しています:

グローバルなファイル使用状況

以下に挙げる他のウィキがこの画像を使っています: