jug7.com
[ home / cgi / juggler / column / diary / bbs / link / welcome ]


source : アイムジャグラー 設定信頼度


#!/usr/bin/perl
# アイムジャグラー 二項分布によるデータのみからの設定信頼度

$cginame = 'imjs.cgi';
$title   = 'アイムジャグラー データからの設定信頼度';

if ($ENV{'REQUEST_METHOD'} eq 'POST') {
    read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
}
foreach $str (split(/&/,$input)) {
    ($name,$value) = split(/=/, $str);
    push(@input, $value);
}
($play, $big, $reg, $reg_che, $grape) = @input;

print "Content-Type: text/html\n\n";

# ヘッダとフォームの表示
print <<"__ HTML __";
<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html lang='ja'>
<head>
<meta http-equiv='Content-Type' content="text/html; charset=shift_jis">
<title>jug7.com - cgi $title</title>
 <style type="text/css"> <!--
   A:hover {color:#ff0000;}
 --></style>
</head>
<body text='#000000' bgcolor='#ffffff' link='#0000ff' alink='#ff0000' vlink='#0000cc'>
<hr>
<b>$title</b><br>
<form action='$cginame' method='POST'>
プレイ数 <input type='text' size=6 name='play' maxlength=4 value='$play'><br>
BIG <input type='text' size=3 name='big' maxlength=4 value='$big'><br>
REG <input type='text' size=3 name='reg' maxlength=4 value='$reg'><br>
REG重複チェ <input type='text' size=3 name='reg_che' maxlength=4 value='$reg_che'><br>
ブドウ<input type='text' size=3 name='grape' maxlength=4 value='$grape'><br>
<br>
<input type='submit' value="開始">
</form>
空欄なら考慮しない。<br>
全設定が均等に設置という仮定のもとに計算。<br>
__ HTML __


# エラーチェックとGET送信
if ($ENV{'REQUEST_METHOD'} ne 'POST') {
    print '<a href=\'imjs_memo.html\'>memo</a> <a href=\'imjs.html\'>source</a> <a href=\'../index.html\'>top へ戻る</a>',"\n",'</body></html>';
    exit;
}

# jug data
@big = ('287.439', '282.483', '282.483', '273.067', '273.067', '268.590'); # 1/x
@reg = ('455.111', '442.811', '348.596', '321.255', '268.590', '268.590');
@reg_che = ('1489.455', '1489.455', '1170.286', '1092.267', '910.222', '910.222');
@grape = ('6.489', '6.489', '6.489', '6.489', '6.489', '6.183');

#------------
#  計算開始
#------------

$bp  = &point(($play/$big), 2) if $big;
$rp  = &point(($play/$reg), 2) if $reg;
$br  = $big + $reg;
$brp = &point(($play/$br), 2) if $br;


for ($i=0; $i<=5; $i++) {
    $p_total = 10**100;

    if ($big or ($big eq '0')) {
        $p_big = (1/$big[$i])**$big * (1-1/$big[$i])**($play-$big); $p_total *= $p_big;
    }
    if ($reg or ($reg eq '0')) {
        $p_reg = (1/$reg[$i])**$reg * (1-1/$reg[$i])**($play-$reg); $p_total *= $p_reg;
    }

    if ($reg_che or ($reg_che eq '0')) {
        $p_reg_che = (1/$reg_che[$i])**$reg_che * (1-1/$reg_che[$i])**($play-$reg_che); $p_total *= $p_reg_che;
    }

    if ($grape or ($grape eq '0')) {
        # (1/$grape[$i]) ** ブドウ回数 の部分
        $g_temp = $grape;
        $g_p_temp = 1;
        while(1) {
            $minus   = ($g_temp>=200) ? 200 : $g_temp;
            $g_temp -= $minus;
            $g_p_temp *= (1/$grape[$i])**$minus * 10**150;
            last if ($g_temp<=0);
        }

        # (1-1/$grape[$i])**($play-$grape) の部分
        $g_temp2   = $play-$grape;
        $g_p_temp2 = 1;
        while(1) {
            $minus2 = ($g_temp2>=3000) ? 3000 : $g_temp2;
            $g_temp2 -= $minus2;
            $g_p_temp2 *= (1-1/$grape[$i])**$minus2 * 10**200;
            last if ($g_temp2<=0);
        }

        $p_total *= $g_p_temp * $g_p_temp2;
    }

    $p_total2 += $p_total;
    push(@p_total, $p_total);
}

# 百分率にする
$p_total2 = $p_total3 if ($p_total3);
for ($i=0; $i<=5; $i++) {
    $per = &point(($p_total[$i]/$p_total2*100), 2) if $p_total2;
    push(@per, $per);
}
# 結果の表示
print '<br>';
if ($big or ($big eq '0')) { print "<b>BIG確率</b> (1/$bp)<br>"; }
if ($reg or ($reg eq '0')) { print "<b>REG確率</b> (1/$rp)<br>"; }
if ($big ne '' && $reg ne '') { print "<b>BR合成確率</b> (1/$brp)<br>"; }

for ($i=1; $i<=6; $i++) { print "設 $i -&gt; $per[$i-1] %<br>\n"; }

print '<a href=\'imjs_memo.html\'>memo</a> <a href=\'imjs.html\'>source</a> <a href=\'../index.html\'>top へ戻る</a><hr>',"\n",'</body></html>';
exit;

# 少数を四捨五入して指定の桁にする
sub point {
    my($value, $fig, $x);
    ($value, $fig) = @_;

    $value = int($value * (10 ** $fig) + 0.5) / (10 ** $fig);
    if ($value =~ /(\d+)\.(\d+)/) { $x = $2; }
    elsif ($value !~ /\./)        { $x =''; $value .= '.'; }
    $value = $value.'0' x ( $fig - length($x) );
    return $value;
}


[ home / cgi / juggler / column / diary / bbs / link / welcome ]