|
289 | 289 | "cell_type": "markdown", |
290 | 290 | "metadata": {}, |
291 | 291 | "source": [ |
292 | | - "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`]():" |
| 292 | + "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`]():" |
293 | 293 | ] |
294 | 294 | }, |
295 | 295 | { |
|
808 | 808 | " end\n", |
809 | 809 | " \n", |
810 | 810 | " # Run the model with new x coordinates, and with parameters \n", |
811 | | - " # fixed to be the inferred values\n", |
| 811 | + " # fixed to be the inferred values.\n", |
812 | 812 | " (new_trace, _) = Gen.generate(model, (new_xs,), constraints)\n", |
813 | 813 | " \n", |
814 | | - " # Pull out the y-values and return them\n", |
| 814 | + " # Pull out the y-values and return them.\n", |
815 | 815 | " ys = [new_trace[(:y, i)] for i=1:length(new_xs)]\n", |
816 | 816 | " return ys\n", |
817 | 817 | "end;" |
|
929 | 929 | "cell_type": "markdown", |
930 | 930 | "metadata": {}, |
931 | 931 | "source": [ |
932 | | - "Now consider the same experiment run with following data set, which has significantly more noise." |
| 932 | + "Now consider the same experiment run with the following data set, which has significantly more noise." |
933 | 933 | ] |
934 | 934 | }, |
935 | 935 | { |
|
994 | 994 | "cell_type": "markdown", |
995 | 995 | "metadata": {}, |
996 | 996 | "source": [ |
997 | | - "Then, we compare the predictions using inference the unmodified and modified model on the `ys` data set:" |
| 997 | + "Then, we compare the predictions using inference of the unmodified and modified models on the `ys` data set:" |
998 | 998 | ] |
999 | 999 | }, |
1000 | 1000 | { |
|
1024 | 1024 | "source": [ |
1025 | 1025 | "Notice that there is more uncertainty in the predictions made using the modified model.\n", |
1026 | 1026 | "\n", |
1027 | | - "We also compare the predictions using inference the unmodified and modified model on the `ys_noisy` data set:" |
| 1027 | + "We also compare the predictions using inference of the unmodified and modified models on the `ys_noisy` data set:" |
1028 | 1028 | ] |
1029 | 1029 | }, |
1030 | 1030 | { |
|
1062 | 1062 | "-------------------------\n", |
1063 | 1063 | "### Exercise\n", |
1064 | 1064 | "\n", |
1065 | | - "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.\n", |
| 1065 | + "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.\n", |
1066 | 1066 | "\n", |
1067 | 1067 | "We have provided you with starter code:" |
1068 | 1068 | ] |
|
1521 | 1521 | "cell_type": "markdown", |
1522 | 1522 | "metadata": {}, |
1523 | 1523 | "source": [ |
1524 | | - "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." |
| 1524 | + "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." |
1525 | 1525 | ] |
1526 | 1526 | }, |
1527 | 1527 | { |
|
1569 | 1569 | "cell_type": "markdown", |
1570 | 1570 | "metadata": {}, |
1571 | 1571 | "source": [ |
1572 | | - "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." |
| 1572 | + "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." |
1573 | 1573 | ] |
1574 | 1574 | }, |
1575 | 1575 | { |
|
1708 | 1708 | "cell_type": "markdown", |
1709 | 1709 | "metadata": {}, |
1710 | 1710 | "source": [ |
1711 | | - "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." |
| 1711 | + "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." |
1712 | 1712 | ] |
1713 | 1713 | }, |
1714 | 1714 | { |
|
1735 | 1735 | " end\n", |
1736 | 1736 | "end\n", |
1737 | 1737 | "\n", |
1738 | | - "# Out full model\n", |
| 1738 | + "# Our full model\n", |
1739 | 1739 | "@gen function changepoint_model(xs::Vector{Float64})\n", |
1740 | 1740 | " node = @trace(generate_segments(minimum(xs), maximum(xs)), :tree)\n", |
1741 | 1741 | " noise = @trace(gamma(1, 1), :noise)\n", |
|
0 commit comments