高校数学の質問スレ(医者・東大卒専用) Part438 (979レス)
高校数学の質問スレ(医者・東大卒専用) Part438 http://rio2016.5ch.net/test/read.cgi/math/1723152147/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
486: 132人目の素数さん [sage] 2024/12/30(月) 03:14:24.14 ID:DAgtZ3Zg # 遷移行列 P <- matrix(c( 0, 0.5, 0.5, 0, 0, # S0: 初戦 A vs B 0, 0, 0, 0.5, 0.5, # S1: A vs C 0, 0, 0, 0.5, 0.5, # S2: B vs C 0.5, 0, 0, 0, 0.5, # S3: 再試合 A vs B 0.5, 0, 0, 0.5, 0 # S4: 再試合 B vs A ), nrow = 5, byrow = TRUE) # 固有値と固有ベクトルの計算 eig <- eigen(t(P)) stationary <- Re(eig$vectors[, which(abs(Re(eig$values) - 1) < 1e-8)]) stationary <- stationary / sum(stationary) # 各プレイヤーの勝率を計算 A_win <- stationary[2] + stationary[4] B_win <- stationary[3] + stationary[5] C_win <- stationary[1] cat("定常分布:\n") print(stationary) cat(sprintf("\nAの勝率: %.3f\n", A_win)) cat(sprintf("Bの勝率: %.3f\n", B_win)) cat(sprintf("Cの勝率: %.3f\n", C_win)) http://rio2016.5ch.net/test/read.cgi/math/1723152147/486
487: 132人目の素数さん [sage] 2024/12/30(月) 03:17:30.79 ID:DAgtZ3Zg (* 遷移行列の定義 *) P = { {0, 0.5, 0.5, 0, 0}, (* S0: 初戦 A vs B *) {0, 0, 0, 0.5, 0.5}, (* S1: A vs C *) {0, 0, 0, 0.5, 0.5}, (* S2: B vs C *) {0.5, 0, 0, 0, 0.5}, (* S3: 再試合 A vs B *) {0.5, 0, 0, 0.5, 0} (* S4: 再試合 B vs A *) }; (* 遷移行列の転置 *) PT = Transpose[P]; (* 固有値と固有ベクトルの計算 *) {eigValues, eigVectors} = Eigensystem[PT]; (* 固有値1に対応する固有ベクトル *) stationaryVector = Select[eigVectors, Norm[PT.# - #] & /@ eigValues == 1 ][[1]]; (* 正規化(確率の総和を1にする) *) stationaryVector = stationaryVector/Total[stationaryVector]; (* 各プレイヤーの勝率を計算 *) AWin = stationaryVector[[2]] + stationaryVector[[4]]; BWin = stationaryVector[[3]] + stationaryVector[[5]]; CWin = stationaryVector[[1]]; (* 結果表示 *) {stationaryVector, AWin, BWin, CWin} http://rio2016.5ch.net/test/read.cgi/math/1723152147/487
488: 132人目の素数さん [sage] 2024/12/30(月) 03:31:36.28 ID:DAgtZ3Zg # 遷移行列 P <- matrix(c( 0, 0.5, 0.5, 0, 0, # S0: 初戦 A vs B 0, 0, 0, 0.5, 0.5, # S1: A vs C 0, 0, 0, 0.5, 0.5, # S2: B vs C 0.5, 0, 0, 0, 0.5, # S3: 再試合 A vs B 0.5, 0, 0, 0.5, 0 # S4: 再試合 B vs A ), nrow = 5, byrow = TRUE) # 固有値と固有ベクトルの計算 eig <- eigen(t(P)) stationary <- Re(eig$vectors[, which(abs(Re(eig$values) - 1) < 1e-8)]) stationary <- stationary / sum(stationary) # 各プレイヤーの勝率を計算 A_win <- stationary[2] + stationary[4] B_win <- stationary[3] + stationary[5] C_win <- stationary[1] cat("定常分布:\n") print(stationary) cat(sprintf("\nAの勝率: %.3f\n", A_win)) cat(sprintf("Bの勝率: %.3f\n", B_win)) cat(sprintf("Cの勝率: %.3f\n", C_win)) http://rio2016.5ch.net/test/read.cgi/math/1723152147/488
489: 132人目の素数さん [sage] 2024/12/30(月) 03:34:00.29 ID:DAgtZ3Zg (* 遷移行列の定義 *) P = { {0, 0.5, 0.5, 0, 0}, (* S0: 初戦 A vs B *) {0, 0, 0, 0.5, 0.5}, (* S1: A vs C *) {0, 0, 0, 0.5, 0.5}, (* S2: B vs C *) {0.5, 0, 0, 0, 0.5}, (* S3: 再試合 A vs B *) {0.5, 0, 0, 0.5, 0} (* S4: 再試合 B vs A *) }; (* 遷移行列の転置 *) PT = Transpose[P]; (* 固有値と固有ベクトルの計算 *) {eigValues, eigVectors} = Eigensystem[PT]; (* 固有値1に対応する固有ベクトル *) stationaryVector = Select[eigVectors, Norm[PT.# - #] & /@ eigValues == 1 ][[1]]; (* 正規化(確率の総和を1にする) *) stationaryVector = stationaryVector/Total[stationaryVector]; (* 各プレイヤーの勝率を計算 *) AWin = stationaryVector[[2]] + stationaryVector[[4]]; BWin = stationaryVector[[3]] + stationaryVector[[5]]; CWin = stationaryVector[[1]]; (* 結果表示 *) {stationaryVector, AWin, BWin, CWin} http://rio2016.5ch.net/test/read.cgi/math/1723152147/489
491: 132人目の素数さん [sage] 2024/12/30(月) 21:13:17.75 ID:DAgtZ3Zg >>490 類似問題のコードを弄るだけなのに クレクレ レス乞食かよ。 http://rio2016.5ch.net/test/read.cgi/math/1723152147/491
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.028s