You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/Introduction to Modeling in Gen.jl
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,9 @@
7
7
# format_version: '1.5'
8
8
# jupytext_version: 1.3.3
9
9
# kernelspec:
10
-
# display_name: Julia 1.0.2
10
+
# display_name: Julia 1.1.1
11
11
# language: julia
12
-
# name: julia-1.0
12
+
# name: julia-1.1
13
13
# ---
14
14
15
15
# # Tutorial: Introduction to Modeling in Gen
@@ -125,7 +125,7 @@ println(trace)
125
125
126
126
Gen.get_args(trace)
127
127
128
-
# The trace also contains the value of the random choices, stored in map from address to value called a *choice map*. This map is available through the API method [`get_choices`]():
128
+
# The trace also contains the value of the random choices, stored in a map from address to value called a *choice map*. This map is available through the API method [`get_choices`]():
129
129
130
130
println(Gen.get_choices(trace))
131
131
@@ -347,10 +347,10 @@ function predict_new_data(model, trace, new_xs::Vector{Float64}, param_addrs)
347
347
end
348
348
349
349
# Run the model with new x coordinates, and with parameters
# Write a modified version the sine model that makes noise into a random choice. Compare the predicted data with the observed data `infer_and_predict` and `plot_predictions` for the unmodified and modified model, and for the `ys_sine` and `ys_noisy` datasets. Discuss the results. Experiment with the amount of inference computation used. The amount of inference computation will need to be higher for the model with the noise random choice.
457
+
# Write a modified version of the sine model that makes noise into a random choice. Compare the predicted data with the observed data using `infer_and_predict` and `plot_predictions` for the unmodified and modified models, and for the `ys_sine` and `ys_noisy` data sets. Discuss the results. Experiment with the amount of inference computation used. The amount of inference computation will need to be higher for the model with the noise as a random choice.
# ## 6. Modeling with an unbounded number of parameters <a name="infinite-space"></a>
669
669
670
-
# Gen's built-in modeling language can be used to express models that use an unbounded number of parameters. This section walks you through development of a model of data that does not a-priori specify an upper bound on the complexity of the model, but instead infers the complexity of the model as well as the parameters. This is a simple example of a *Bayesian nonparametric* model.
670
+
# Gen's built-in modeling language can be used to express models that use an unbounded number of parameters. This section walks you through development of a model of data that does not apriori specify an upper bound on the complexity of the model, but instead infers the complexity of the model as well as the parameters. This is a simple example of a *Bayesian nonparametric* model.
# The data set on the left appears to be best explained as a contant function with some noise. The data set on the right appears to include two changepoints, with a constant function in between the changepoints. We want a model that does not a-priori choose the number of changepoints in the data. To do this, we will recursively partition the interval into regions. We define a Julia data structure that represents a binary tree of intervals; each leaf node represents a region in which the function is constant.
692
+
# The data set on the left appears to be best explained as a contant function with some noise. The data set on the right appears to include two changepoints, with a constant function in between the changepoints. We want a model that does not apriori choose the number of changepoints in the data. To do this, we will recursively partition the interval into regions. We define a Julia data structure that represents a binary tree of intervals; each leaf node represents a region in which the function is constant.
# Because we only sub-divide an interval with 30% probability, most of these sampled traces have only one segment.
757
757
758
-
# Now that we have generative function that generates a random piecewise-constant function, we write a model that adds noise to the resulting constant functions to generate a data set of y-coordinates. The noise level will be a random choice.
758
+
# Now that we have a generative function that generates a random piecewise-constant function, we write a model that adds noise to the resulting constant functions to generate a data set of y-coordinates. The noise level will be a random choice.
759
759
760
760
# +
761
761
# get_value_at searches a binary tree for
@@ -774,7 +774,7 @@ function get_value_at(x::Float64, node::InternalNode)
Copy file name to clipboardExpand all lines: tutorials/Modeling with Black-Box Julia Code.jl
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,9 @@
7
7
# format_version: '1.5'
8
8
# jupytext_version: 1.3.3
9
9
# kernelspec:
10
-
# display_name: Julia 1.0.2
10
+
# display_name: Cora Julia 1.1.1
11
11
# language: julia
12
-
# name: julia-1.0
12
+
# name: cora-julia-1.1
13
13
# ---
14
14
15
15
# # Modeling with black-box Julia code
@@ -88,7 +88,7 @@ info = Dict("scene" => scene)
88
88
viz =Viz(viz_server, joinpath(@__DIR__, "../inverse-planning/overlay-viz/dist"), info)
89
89
displayInNotebook(viz)
90
90
91
-
# Next, we load a file that defines a `Path` data type (a sequence of `Points`), and a `plan_path` method, which uses a path planning algorithm based on rapidly exploring random tree (RRT, [1]) to find a sequence of `Point`s beginning with `start` and ending in `dest` such that the line segment between each consecutive pair of points does nt intersect any obstacles in the scene. The planning algorithm may fail to find a valid path, in which case it will return a value of type `Nothing`.
91
+
# Next, we load a file that defines a `Path` data type (a sequence of `Points`), and a `plan_path` method, which uses a path planning algorithm based on rapidly exploring random tree (RRT, [1]) to find a sequence of `Point`s beginning with `start` and ending in `dest` such that the line segment between each consecutive pair of points does not intersect any obstacles in the scene. The planning algorithm may fail to find a valid path, in which case it will return a value of type `Nothing`.
# In this visualization, the start location is represented by a blue dot, and the destination is represented by a red dot. The measured coordinates at each time point are represented by black dots. The path, if path planning was succesfull, is shown as a gray line fro the start point to the destination point. Notice that the speed of the agent is different in each case.
220
+
# In this visualization, the start location is represented by a blue dot, and the destination is represented by a red dot. The measured coordinates at each time point are represented by black dots. The path, if path planning was succesfull, is shown as a gray line from the start point to the destination point. Notice that the speed of the agent is different in each case.
0 commit comments