Skip to content

Commit

Permalink
Set a default argument of num_reps=1 for the case of `init::Vector{…
Browse files Browse the repository at this point in the history
…Int}`
  • Loading branch information
oyamad committed Jan 12, 2016
1 parent fe0ea34 commit dbe236e
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/mc_tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit dbe236e

Please sign in to comment.