-
Notifications
You must be signed in to change notification settings - Fork 53
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the error below, no issues.
rst_files/finite_markov.rst
Outdated
|
||
# == Compute fraction of time spent unemployed, for each n == # | ||
X_bar = cumsum(X.==1) ./ 1:N |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is erroring on 1.0 and 0.7. I think the issue is that you can't divide elementwise by a range. But this seems to work:
julia> X_bar = cumsum(X.==1) ./ collect(1:N)
10000-element Array{Float64,1}:
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
0.9285714285714286
0.8666666666666667
0.8125
0.7647058823529411
⋮
0.49759615384615385
0.49754631947921885
0.4974964950931304
0.49744668068489034
0.4973968762515018
0.49734708178996895
0.4972972972972973
0.49724752277049344
0.49719775820656525
0.49714800360252176
0.49709825895537324
0.4970485242621311
0.4969987995198079
0.4969490847254176
0.4968993798759752
0.49684968496849685
0.4968
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That collect
should stay. Thanks for catching that.
rst_files/finite_markov.rst
Outdated
@@ -1384,7 +1384,7 @@ compare it to the stationary probability. | |||
X = simulate_indices(mc, N; init = x0) | |||
|
|||
# == Compute fraction of time spent unemployed, for each n == # | |||
X_bar = cumsum(X.==1) ./ 1:N | |||
X_bar = cumsum(X.==1) ./ collect(1:N) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a precedence thing rather than broadcasting with ranges. Try X_bar = cumsum(X.==1) ./ (1:N)
to see if adding brackets helps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can confirm this is the preferred solution. You can make a small edit to change collect
to a ()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stick with the brackets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, will change this to (1:N)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
No description provided.