- Random Data Generator a. Univariate gaussian data generator
Expectation value or mean:
Variance:
Output: A data point from
Generating values from normal distribution
You have to handcraft your geneartor based on one of the approaches given in the hyperlink.
You can use uniform distribution function (Numpy)
2. Sequential Estimator
Sequential estimate the mean and variance
Data is given from the univariate gaussian data generator (1.a). Input: as in (1.a) Function:
Call (1.a) to get a new data point from
Use sequential estimation to find the current estimates to and
Repeat steps above until the estimates converge.
Output: Print the new data point and the current estimiates of and in each iteration.
Notes
You should derive the recursive function of mean and variance based on the sequential esitmation.
Sample input & output ( for reference only )
1 Data point source function: N(3.0, 5.0)
2
- Add data point: 234685454257290
- Mean = 408993960833291 Variance = 0.030383455464755956
- Add data point: 519242879651157
- Mean = 445743600439247 Variance = 1.875958150575018
- Add data point: 347113997201991
- Mean = 171086199629932 Variance = 1.633278676389248
- Add data point: 979491998496083
- Mean = 532767359403163 Variance = 8.723325264636875
- Add data point: 603448448693051
- Mean = 544547540951477 Variance = 7.270131583917285
- Add data point: 127197937610908
- Mean = 627783311902824 Variance = 6.273110519038578
- Add data point: 992735798186870
- Mean = 798402372688330 Variance = 5.692747751482052
17
18
19
- Add data point: 233592159021013
- Mean = 961576104513964 Variance = 5.045715437349161
- Add data point: 529990930040463
- Mean = 961883688294010 Variance = 5.043159812425648
- Add data point: 125210345431449
- Mean = 960890354955524 Variance = 5.042255747918937
3. Baysian Linear regression
Input
The precision (i.e., b) for initial prior
All other required inputs for the polynomial basis linear model geneartor (1.b)
Function
Call (1.b) to generate one data point
Update the prior, and calculate the parameters of predictive distribution Repeat steps above until the posterior probability converges.
Output
Print the new data point and the current paramters for posterior and predictive distribution.
After probability converged, do the visualization
Ground truth function (from linear model generator)
Final predict result
At the time that have seen 10 data points
At the time that have seen 50 data points
Except ground truth, you have to draw those data points which you have seen before
Draw a black line to represent the mean of function at each point
Draw two red lines to represent the variance of function at each point
In other words, distance between red line and mean is ONE variance
Hint: Online learning
Sample input & output (for reference only)
- b = 1, n = 4, a = 1, w = [1, 2, 3, 4]
30313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | Predictive distribution ~ N(0.06869, 1.66008)-Add data point (-0.19330, 0.24507):Postirior mean:0.57609723130.2450231522-0.08018424530.0504992402Posterior variance:0.2867129751, 0.1311255325, -0.0767580827, 0.04384885420.1311255325, 0.7892001707, 0.1242887609, -0.0801412282-0.0767580827, 0.1242887609, 0.9176812972, 0.05415755400.0438488542, -0.0801412282, 0.0541575540, 0.9642058389Predictive distribution ~ N(0.62305, 1.34848)–Add data point (-0.76990, -0.34768):Postirior mean: 0.91074966751.92654998853.11192971294.1312375189Posterior variance:0.0051883836, -0.0004416700, -0.0086000319, 0.0008247001-0.0004416700, 0.0401966605, 0.0012708906, -0.0554822477-0.0086000319, 0.0012708906, 0.0265353911, -0.00312058750.0008247001, -0.0554822477, -0.0031205875, 0.0937197255Predictive distribution ~ N(-0.61566, 1.00921)-Add data point (0.36500, 2.22705):Postirior mean:0.91074045831.92652250903.11194087404.1312734131Posterior variance:0.0051731092, -0.0004872471, -0.0085815201, 0.0008842340 |
- b = 100, n = 4, a = 1, w = [1, 2, 3, 4]
- b = 1, n = 3, a = 3, w = [1, 2, 3]
Reviews
There are no reviews yet.