From 1a36aaa3c6f8c34f12b1609fad0fc249327ef6d8 Mon Sep 17 00:00:00 2001 From: Daisuke Oyama Date: Tue, 12 Jan 2016 11:44:30 +0900 Subject: [PATCH] Revert "Set a default argument of `num_reps=1` for the case of `init::Vector{Int}`" This reverts commit dbe236ed439e3b3dbd73bd902ea31d1694777ab1. --- src/mc_tools.jl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mc_tools.jl b/src/mc_tools.jl index a14dfd71..8d5da5f5 100644 --- a/src/mc_tools.jl +++ b/src/mc_tools.jl @@ -306,19 +306,24 @@ The sample path from the `j`-th repetition of the simulation with initial state - `mc::MarkovChain` : MarkovChain instance. - `ts_length::Int` : Length of each simulation. - `init::Vector{Int}` : Vector containing initial states. -- `;num_reps::Int(1)` : Number of repetitions of simulation. +- `;num_reps::Union{Int, Void}(nothing)` : 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)*num_reps. +(ts_length, k), where k = length(init) if num_reps=nothing, and k = +length(init)*num_reps otherwise. """ function simulate(mc::MarkovChain, ts_length::Int, init::Vector{Int}; - num_reps::Int=1) - k = length(init) * num_reps + num_reps::Union{Int, Void}=nothing) + k = length(init) + if num_reps == nothing + num_reps = 1 + end + k *= num_reps X = Array(Int, ts_length, k) X[1, :] = repmat(init, num_reps)