Skip to content

Instantly share code, notes, and snippets.

@tabris2012
Created May 10, 2012 03:08
Show Gist options
  • Save tabris2012/2650789 to your computer and use it in GitHub Desktop.
Save tabris2012/2650789 to your computer and use it in GitHub Desktop.
for ($i =0; $i < $K; $i++) { #遷移確率を求める
for ($j =0; $j < $K; $j++) {
$t0 =0;
$t1 =0;
for ($u =0; $u < @state -1; $u++) { #個数を数える
if ($state[$u] == $i) {
$t0++;
if ($state[$u +1] == $j) {
$t1++;
}
}
}
#遷移確率を計算
push @{$trans[$i]}, (1- $alpha) * $t1 / $t0 + $alpha / $K;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment