|
281 | 281 | "cell_type": "markdown", |
282 | 282 | "metadata": {}, |
283 | 283 | "source": [ |
284 | | - "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`]():" |
| 284 | + "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`]():" |
285 | 285 | ] |
286 | 286 | }, |
287 | 287 | { |
|
796 | 796 | " end\n", |
797 | 797 | " \n", |
798 | 798 | " # Run the model with new x coordinates, and with parameters \n", |
799 | | - " # fixed to be the inferred values\n", |
| 799 | + " # fixed to be the inferred values.\n", |
800 | 800 | " (new_trace, _) = Gen.generate(model, (new_xs,), constraints)\n", |
801 | 801 | " \n", |
802 | | - " # Pull out the y-values and return them\n", |
| 802 | + " # Pull out the y-values and return them.\n", |
803 | 803 | " ys = [new_trace[(:y, i)] for i=1:length(new_xs)]\n", |
804 | 804 | " return ys\n", |
805 | 805 | "end;" |
|
911 | 911 | "cell_type": "markdown", |
912 | 912 | "metadata": {}, |
913 | 913 | "source": [ |
914 | | - "Now consider the same experiment run with following data set, which has significantly more noise." |
| 914 | + "Now consider the same experiment run with the following data set, which has significantly more noise." |
915 | 915 | ] |
916 | 916 | }, |
917 | 917 | { |
|
970 | 970 | "cell_type": "markdown", |
971 | 971 | "metadata": {}, |
972 | 972 | "source": [ |
973 | | - "Then, we compare the predictions using inference the unmodified and modified model on the `ys` data set:" |
| 973 | + "Then, we compare the predictions using inference of the unmodified and modified models on the `ys` data set:" |
974 | 974 | ] |
975 | 975 | }, |
976 | 976 | { |
|
998 | 998 | "source": [ |
999 | 999 | "Notice that there is more uncertainty in the predictions made using the modified model.\n", |
1000 | 1000 | "\n", |
1001 | | - "We also compare the predictions using inference the unmodified and modified model on the `ys_noisy` data set:" |
| 1001 | + "We also compare the predictions using inference of the unmodified and modified models on the `ys_noisy` data set:" |
1002 | 1002 | ] |
1003 | 1003 | }, |
1004 | 1004 | { |
|
1034 | 1034 | "-------------------------\n", |
1035 | 1035 | "### Exercise\n", |
1036 | 1036 | "\n", |
1037 | | - "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", |
| 1037 | + "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", |
1038 | 1038 | "\n", |
1039 | 1039 | "We have provided you with starter code:" |
1040 | 1040 | ] |
|
1479 | 1479 | "cell_type": "markdown", |
1480 | 1480 | "metadata": {}, |
1481 | 1481 | "source": [ |
1482 | | - "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." |
| 1482 | + "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." |
1483 | 1483 | ] |
1484 | 1484 | }, |
1485 | 1485 | { |
|
1523 | 1523 | "cell_type": "markdown", |
1524 | 1524 | "metadata": {}, |
1525 | 1525 | "source": [ |
1526 | | - "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." |
| 1526 | + "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." |
1527 | 1527 | ] |
1528 | 1528 | }, |
1529 | 1529 | { |
|
1652 | 1652 | "cell_type": "markdown", |
1653 | 1653 | "metadata": {}, |
1654 | 1654 | "source": [ |
1655 | | - "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." |
| 1655 | + "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." |
1656 | 1656 | ] |
1657 | 1657 | }, |
1658 | 1658 | { |
|
1677 | 1677 | " end\n", |
1678 | 1678 | "end\n", |
1679 | 1679 | "\n", |
1680 | | - "# Out full model\n", |
| 1680 | + "# Our full model\n", |
1681 | 1681 | "@gen function changepoint_model(xs::Vector{Float64})\n", |
1682 | 1682 | " node = @trace(generate_segments(minimum(xs), maximum(xs)), :tree)\n", |
1683 | 1683 | " noise = @trace(gamma(1, 1), :noise)\n", |
|
0 commit comments