From dbe236ed439e3b3dbd73bd902ea31d1694777ab1 Mon Sep 17 00:00:00 2001 From: Daisuke Oyama Date: Tue, 12 Jan 2016 11:09:54 +0900 Subject: [PATCH] Set a default argument of `num_reps=1` for the case of `init::Vector{Int}` --- src/mc_tools.jl | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/mc_tools.jl b/src/mc_tools.jl index 927970f8..26b1bd36 100644 --- a/src/mc_tools.jl +++ b/src/mc_tools.jl @@ -303,24 +303,19 @@ Simulate time series of state transitions of the Markov chain `mc`. - `mc::MarkovChain` : MarkovChain instance. - `ts_length::Int` : Length of each simulation. - `init::Vector{Int}` : Vector containing initial states. -- `;num_reps::Union{Int, Void}(nothing)` : Number of repetitions of simulation. +- `;num_reps::Int(1)` : Number of repetitions of simulation. ##### Returns - `X::Array{Int}` : Array containing the sample paths as columns, of shape -(ts_length, k), where k = length(init) if num_reps=nothing, and k = -length(init)*num_reps otherwise. +(ts_length, k), where k = length(init)*num_reps. """ function simulate(mc::MarkovChain, ts_length::Int, init::Vector{Int}; - num_reps::Union{Int, Void}=nothing) - k = length(init) - if num_reps == nothing - num_reps = 1 - end - k *= num_reps + num_reps::Int=1) + k = length(init) * num_reps X = Array(Int, ts_length, k) X[1, :] = repmat(init, num_reps)