-
Notifications
You must be signed in to change notification settings - Fork 0
/
paper_fig7.m
79 lines (59 loc) · 2.25 KB
/
paper_fig7.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
% DART software - Copyright UCAR. This open source software is provided
% by UCAR, "as is", without charge, subject to all terms of use at
% http://www.image.ucar.edu/DAReS/DART/DART_download
% This script was used with Matlab 2016b to generate figures for
% A Quantile Conserving Ensemble Filter Framework. Part I: Updating an Observed Variable
% by Jeffrey Anderson
% which was submitted to Monthly Weather Review.
% This script generates Figure 7.
% The continuous prior is a normal while the likelihood is an exponential.
ens_size = 10;
% Create the random draw for the prior ensemble
r_seed = 12;
rng(r_seed);
y_prior = normrnd(2, 1, 1, ens_size);
% Define the likelihood, a single parameter lambda for the exponential
like_lambda = 1;
% Set of uniformly spaced horizontal points for doing plots
y = -3:0.001:10;
% Get the Normal/Exponential ensemble increments and prior and posterior points for plotting
[ne_incs, ne_prior_pts, ne_post_pts, ne_like_pts, err] = obs_increment_normal_exp(y_prior, like_lambda, y);
% Posterior ensemble is prior plus increments
ne_post = y_prior + ne_incs;
% Put on the zero lines below the different curves
bx = [min(y), max(y)];
by = [1 1];
plot(bx, by * 0, 'k');
hold on
plot(bx, by * -1, 'k');
plot(bx, by * -1.75, 'k');
% Plot the continuous prior at the top on its own axes
l_wid = 3;
ast_width = 1.5;
plot(y, ne_prior_pts, 'b', 'linewidth', l_wid);
hold on
% Plot the likelihood
offset = 1;
plot(y, ne_like_pts - offset, 'b', 'linewidth', l_wid)
% Plot the continuous analysis
offset = 1.75;
plot(y, ne_post_pts - offset, 'b', 'linewidth', l_wid);
% Plot the prior ensemble just below the continuous prior
ay = ones(size(y_prior));
plot(y_prior, ay * -.1, 'k*', 'linewidth', ast_width);
% Plot the posterior ensemble
plot(y_prior + ne_incs, ay * -1.9, 'b*', 'linewidth', ast_width);
% Make things easily visible
pbaspect([1.5 1 1]);
set(gca, 'fontsize', 16, 'linewidth', 2);
set(gca, 'YTick', [-1.75 -1.25 -1 -0.5 0 0.5]);
tick_lab = get(gca, 'YTickLabel');
tick_lab = {0 0.5 0 0.5 0 0.5};
set(gca, 'YTickLabel', tick_lab);
axis([-1, 6, -2, 0.5]);
xlabel 'Observation';
ylabel 'Probability';
% Label the panels
text(5, 0.3, 'Prior', 'Fontsize', 16);
text(4.5, -0.6, 'Likelihood', 'Fontsize', 16);
text(4.5, -1.4, 'Analysis', 'Fontsize', 16);