玉を取り出す確率最大化問題

めるきたんのコメントを受けて、一般化して考え直してみよう。

n個の玉A, n個の玉Bが合わせて2n個あり、2つの箱a,bに分けて入れる。
a,bをまず無作為に選び、その後選んだ箱から1個の玉を取り出すとき、取り出した玉がAである確率を最大にするためには、どのように玉をa,bに入れておくのが最善だろうか。

Windowsでシンボリックリンクを貼る

  • Vista以上の場合。

mklinkコマンドがある。
作成

mklink リンクファイル ターゲットファイル
mklink /d リンクフォルダ ターゲットフォルダ

削除

del リンクファイル
rd リンクフォルダ
  • XPの場合

linkd.exe を入れる。

linkd リンクフォルダ ターゲットフォルダ

ファイルにリンクを貼ることはできない。

数学二問

赤玉50個と白玉50個がある。これを2つの箱に分けて入れる。
無作為に2つの箱から1つを選び、その中から無作為に1つの玉を選ぶことを考える。
このとき、白玉が選ばれる確率を最大にするには、どのように玉を箱に入れるべきか。

3点(1,1), (2,3), (3,2)において
\sum_{i=1}^3 |y_i - (ax_i + b)|
を最小にするような実数a, bを求めよ。

Windows 7 で ping を使う

ping: socket: Operation not permitted

とか言われてpingが使えなかった。

  • windows7 はデフォルトpingができない(ping: socket: Operation not permitted)
  1. ファイアウォールツール起動
    1. [スタート]→[コントロールパネル]で「ファイアウォール」で検索
    2. Windowsファイアウォール」→「詳細設定」で「セキュリティが強化されたWindowsファイアウォール」が起動(なんだこの手順)
  2. 左メニュー「受信の規則」選択
  3. 右メニュー「新しい規則」選択
  4. カスタム→全てのプログラム→プロトコルの種類「ICMPv4」→任意のIPアドレス→接続を許可する→名前にICMPとか入れて完了(なんでも良い)
  5. 左メニュー「送信の規則」も同様に設定する

これやってもできなかったんだが。どうすれば。

続きを読む

JavaScript & DOMで動的table生成

できない。
最後の手段として、stringでhtmlを吐き出すというのがあるが、これはできれば使いたくない。

<html>
<head>
<title></title>
<script type="text/javascript">
function start(tbl) {
// get the reference for the body
// var body = document.getElementsByTagName("body")[0];
if (typeof tbl == "table") tbl = document.getElementsById(tbl); 

// creates a <table> element and a <tbody> element
var tblBody = document.createElement("tbody");

// creating all cells
for (var j = 0; j < 2; j++) {
// creates a table row
var row = document.createElement("tr");

for (var i = 0; i < 2; i++) {
// Create a <td> element and a text node, make the text
// node the contents of the <td>, and put the <td> at
// the end of the table row
var cell = document.createElement("td");
var cellText = document.createTextNode("繧サ繝ォ縺ッ "+j+" 陦^Z "+i+" 蛻^Z 縺ァ縺^Z");
cell.appendChild(cellText);
row.appendChild(cell);
}

// add the row to the end of the table body
tblBody.appendChild(row);
}

// put the <tbody> in the <table>
tbl.appendChild(tblBody);
test-table_2.html:33Uncaught TypeError: Object tblid has no method 'appendChild'
test-table_2.html:33Uncaught TypeError: Object tblid has no method 'appendChild'
// appends <table> into <body>
// body.appendChild(tbl);
// sets the border attribute of tbl to 2;
tbl.setAttribute("border", "2");
}
</script>
</head>
<body>
<table id="tblid">
</table>
<p>
test
</p>
<button onclick="start('tblid');">Display Table</button>
</body>
</html>

こいつを読み込ませたら

Uncaught TypeError: Object tblid has no method 'appendChild' 13
Uncaught TypeError: Object tblid has no method 'appendChild'

と言われる。tableの子ノードってtbodyじゃないの常識的に考えて。

*[Linux] Blogiloでfc2ブログを書く

  1. Blogを選択して Add Blog... を選択
  2. Blog/Homepage URL: に http://blog.fc2.com/xmlrpc.php を入力
  3. Username と Password を登録
  4. Auto-configure を押すと、成功すれば、ブログ名が Title に表示されます。
  5. AdvancedタブでAPIMovableType API として Fetch ボタンをクリック
  6. OKで閉じる。