Module:SummonProbabilities

local p = {} local AMC = require 'Module:AbsorbingMarkovChain' local matrix = require 'Module:Matrix' local statistics = require 'Module:User:Ale1991/Statistics'

function p.summonProbabilities local startProbability=6/100 local endProbability = 12/100 local probabilityIncrement=0.25/100 local n=(endProbability-startProbability)/probabilityIncrement

local probabilityArray={} local probability=startProbability for i=1,n+1 do		probabilityArray[i]=probability probability=probability+probabilityIncrement end

local l=(#probabilityArray)+1 local Pmatrix=matrix.new(l,l) for k,v in ipairs(probabilityArray) do --		local t=(k-1)*6+1 --		for i=1,5 do --			Pmatrix[t][t+i]=statistics.BinomialDistribution(5,i,v,1-v) --		end --		for j=1,5 do --			Pmatrix[t+j][1]=1 --		end --		Pmatrix[t][t+6]=1-statistics.BinomialDistribution(5,0,v,1-v) local P0=statistics.BinomialDistribution(5,0,v,1-v) Pmatrix[k][k+1]=P0 Pmatrix[k][1]=1-P0 end Pmatrix[l][1]=1

local canonical=AMC.Properties(Pmatrix) local stepsVariance=canonical["stepsVariance"] local N2=canonical["visitsVariance"] local TT=canonical["stepsNumber"] local H=canonical["transientProbabilities"] local B=canonical["absorbingProbabilities"] local N=canonical["fundamentalMatrix"]

local T="" T=T .. Pmatrix:toWikitable T=T .. "\ncanonical P\n" T=T .. canonical["P"]:toWikitable T=T .. "stepsVariance\n" .. stepsVariance:toWikitable T=T .. "\nvisitsVariance\n" .. N2:toWikitable T=T .. "\nstepsNumber\n" .. TT:toWikitable T=T .. "\ntransientProbabilities\n" .. H:toWikitable T=T .. "\nabsorbingProbabilities\n" .. B:toWikitable T=T .. "\nfundamentalMatrix\n" .. N:toWikitable return T end

return p