Created
May 17, 2012 03:08
-
-
Save tabris2012/2715919 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#隠れ状態から属性を推定する | |
for ($i =0; $i < $K; $i++) { #状態0から順に処理 | |
@attr = (0, 0, 0, 0); #各行の示唆ベクトルを足し合わせていく | |
$t0 =0; | |
for ($j =0; $j < @$lineList; $j++) { | |
if ($state[$j] == $i) { | |
$t0++; #推定状態の数 | |
for ($u =0; $u < @attr; $u++) { #対応するベクトルの要素を足す | |
$attr[$u] += ${$vector[$j]}[$u]; | |
} | |
} | |
} | |
for ($j =0; $j < @attr; $j++) { | |
if ($attr[$j] > $t0 /2) { #半分より大きかったら | |
push @stateAttr, $j +1; | |
last; | |
} | |
} | |
if ($j == @attr) { #どの属性でもない | |
push @stateAttr, 0; | |
} | |
} | |
@vector = (); | |
for ($j =0; $j < @$lineList; $j++) { #属性に応じて行を分類 | |
push @{$vector[$stateAttr[$state[$j]] -1]}, $$lineList[$j]; | |
} | |
return @vector; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment