ruby/strategy.rb
# returns array[64]
#
# solve x = Ux,
# where U is the transition probability matrix, x is the vector of stationary probability
returns array[64]
solve x = Ux,
where U is the transition probability matrix, x is the vector of stationary probability
returns array [ 64 ] solve x = Ux where U is the transition probability matrix x is the vector of stationary probability
def stationary_prob(e, b_strategy)
    require 'pry'
    u = _U_matrix(e, b_strategy)
    N.times {|i| u[i][i] -= 1.0 } 
    N.times {|i| u[N-1][i] += 1.0 }   
    u = NMatrix[*u]
    b = Array.new(N) { Array.new(1, 0.0) }
    b[N-1][0] = 1.0
    b = NMatrix[*b]
    u.solve(b).to_a.flatten
  end
def stationary_prob ( e , b_strategy ) require 'pry' u = _U_matrix ( e , b_strategy ) N . times { | i | u [ i ] [ i ] -= 1.0 } N . times { | i | u [ N - 1 ] [ i ] += 1.0 } u = NMatrix [ * u ] b = Array . new ( N ) { Array . new ( 1 , 0.0 ) } b [ N - 1 ] [ 0 ] = 1.0 b = NMatrix [ * b ] u . solve ( b ) . to_a . flatten end
returns array[64]
solve x = Ux,
where U is the transition probability matrix, x is the vector of stationary probability
returns array [ 64 ] solve x = Ux where U is the transition probability matrix x is the vector of stationary probability
# subtract unit matrix # normalization condition
e
b_strategy