• Keine Ergebnisse gefunden

Disclosure statement

Appendix 2. Filter algorithms for practical im- im-plementation

wj(wj− ˆwj)/Nr compute residual weights and normalise

end for

I RP R(w,ˆ Ne,Nr) sample additional indices IctoNeI R store extra indices at end of arrayI end if

returnI end function

indexIRN˜e which can then be used to select the sampled particlesxj = xI(j)for j = 1: ˜Ne. Note, that we used the PR method to obtain an array I RRNr with the indices of the additional sampled particles, which we then stored in the remaining empty cells of the index arrayIRNe.

Note, that this method reduces the sampling noise, but not as much as the SUR method.

Appendix 2. Filter algorithms for practical im-plementation

This Appendix contains practical pseudo-algorithms of all the ensemble filter methods presented in Sections5–7. To discuss the computational cost of each method in Section9.4we used the algorithms presented in this appendix because for some filter methods they are more computationally efficient or numerically stable than mathematically elegant versions given in Section5.

The algorithms are written in the way one would implement them efficiently in Fortran. For compactness, the algorithms don’t show that the final step of the ensemble filters can usually be written in a blocked form, so that only the allocation one large ensemble arrayX is required. This is different for the MLEF, where two arrays of sizeNx×Neare required. If indices are given for matrices, the notation follows Fortran in that the first index defines the row, while the second index specifies the column.

Note, that in all the algorithms that follow in this appendix any variable with a number subscript is a temporary variable used to

Algorithm 4EnKF (forNy>Ne/2, see Section5.1)

xf mean ofXf (Nx×1)

HXf H Xf

Ens. predicted obs.; (Ny×Ne)

HXf mean ofHXf (Ny×1)

HXf HXf HXf Ens. predicted pert.; (Ny×Ne) HPH N−11 HXf

HXfT

(Ny×Ny)

AHPH+R (Ny×Ny)

Gen. obs. ensembleY (Ny×Ne)

DYHXf (Ny×Ne)

SolveAC=DforC (Ny×Ne)

E HXfT

C (Ny×Ne)

XXfx (Ny×Ne)

XaXf+(N1)XE (Ny×Ne)

Algorithm 5SEIK, see Section5.2

xf mean ofXf (Nx×1)

Hxf H xf

Ens. predicted obs.; (Ny×1)

dyHxf (Ny×1)

HXf H Xf

(Ny×Ne) HL(HX)L (Ny×Ne1) B1R1HL (Ny×Ne1) InitialiseC1(N1)ATA (Ne1×Ne1) C2ρC1+(HL)TB1 (Ne1×Ne1)

d1B1d (Ne1×1)

SolveC2e=d1 (Ne1×1)

wAe (Ne×1)

TTTC2 Cholesky decomp.; (Ne1×Ne1)

Initialise (Ne1×Ne)

SolveTI=R (Ne1×Ne)

W N−11 AT (Ne×Ne)

WW+w (Ne×Ne)

XaXf+XfW (Nx×Ne)

reduce the computational time and storage space needed for the algorithm. Further, for ease of reading these algorithms, we use abbreviations: SVD for singular value decomposition and EVD for eigenvalue decomposition. The values in the right column of each algorithm give the dimension of the resulting array, which helps to determine the computational cost of the operations.

Below, we use the notationH Xf

as a shorthand notation for applying the possibly non-linear observation operator H individually to each ensemble state inXf.

Algorithm 6ESSE, see Section5.3

dyH(xf) (Ny×1)

xf mean ofXf (Nx×1)

forj=1 toNedo Form ens. pert. matr.

Xjf xjfxf (Nx×Ne) end for

UVTXf Compute SVD; (Nx×Ne)

E Ne11T Normalised e.g.values; (Nx×Nx)

q12 (1×1)

UqU(1:q1,:) (Nx×q1) EqE(1:q1,1:q1) (q1×q1)

r1 Set tolerance; (1×1)

repeat Find min. covar. matr.

q1q1+1 (1×1)

Uq1U(1:q1,:) (Nx×q1) Eq1E(1:q1,1:q1) (q1×q1) AE1q1/2UTq1UqE1q/2 (q×q1)

ρTr(A)/Tr(Eq) (1×1)

UqUq1 (Nx×q1)

EqEq1 (q1×q1)

untilρ >r

VTq V(:,1:q1)T (q1×Ne)

C1HUq (Ny×q1)

TC1EqCT1+R Compute EVD; (Ny×Ny) Finv−1T (Ny×Ny) SC1E1q/2VTq (q1×Ny) C2STFinv (q1×Ny) AIC2S (q1×q1)

ZZTA Compute EVD; (q1×q1)

wN1

e1SqF−1d (q1×1)

WZ1/2ZT (q1×q1)

WW+w (Ne×Ne)

XaXf+XfW (Nx×Ne)

Algorithm 7ETKF, see Section5.4

xf mean ofXf (Nx×1)

Hxf H xf

Ens. predicted obs.; (Ny×1)

dyHxf (Ny×1)

HXf H Xf

(Ny×Ne) HXf HXf Hxf Ens. predic. obs. perturb.;(Ny×Ne) CR−1HXf (Ny×Ne) A1(N1)I (Ne×Ne) A2A1+

HXfT

C (Ne×Ne)

Xf XfXf Ens. perturb.; (Nx×Ne)

DCTd (Ne×1)

UUTA2 Compute EVD; (Ne×Ne)

w1UTD (Ne×1)

forj=1 toNedo Scale for each ens. member w2(j)w1(j)1(j,j) (Ne×1) end for

wUw2 (Ne×1)

forj=1 toNedo Scale for each ens. member W1(:,j)

(j,j)U(:,j) (Ne×Ne) end for

WW1UT (Ne×Ne)

WW+w (Ne×Ne)

XaXf+XfW (Nx×Ne)

Algorithm 8EAKF, see Section5.5

xf mean ofXf (Nx×1)

Hxf H xf

Ens. predicted obs.; (Ny×1)

dyHxf (Ny×1)

HXf H Xf

(Ny×Ne) HXf HXf Hxf Ens. predic. obs. perturb.;(Ny×Ne) Xf XfXf Ens. perturb.; (Nx×Ne) S˜ N11R−1HXf (Ny×Ne)

UV← ˜S Compute SVD; (Ny×Ne)

ZGXf Compute SVD; (Nx×Ne)

W1ZXf (Ne×Ne)

forj=1 toNedo Scale for each ens. member b(j)1+2(j,j) (Ne×1) W2(:,j) 1

(j,j)b(j)W1(:,j) (Ne×Ne) end for

WUW2 (Ne×Ne)

forl=1 toNydo Scale for each onbservation c1(l)b(l)1

R(l,l)d(l) (Ny×1)

end for

c2Vc1 (Ny×1)

forj=1 toNedo

c3(j)(j,j)c2(j) (Ne×1) end for

wN−11 Uc3 (Ne×1)

WW+w (Ne×Ne)

XaXf+XfW (Nx×Ne)

Algorithm 9EnSRF, see Section5.6

xf compute mean ofXf (Nx×1)

Xjf xjx, forj=1, . . . ,Ne (Nx×Ne)

SHX (Ny×Ne)

I1SST (Ny×Ny)

I2I1+(N1)R (Ny×Ny)

TI2 Compute EVD; (Ny×Ny)

G1 1 (Ny×Ny)

G2STG1 (Ne×Ny)

UVG2 Compute SVD; (Ne×Ny)

A

I2 (1×Ne)

W1UA (Ne×Ny)

W2W1UT (Ne×Ne) dyH

x

(Ny×1)

w1Td (Ny×1)

w21w1 (Ny×1)

w3w2 (Ny×1)

w4Sw3 (Ne×1)

WW2+[w4, . . . ,w4] (Ne×Ne)

Xa1

xf, . . . ,xf

form anNx×Nymatrix with ens. forecast mean in each column

XaXa1+XfW (Nx×Ne)

Algorithm 10Serial EnSRF, see Section5.7

xf compute mean ofXf (Nx×1)

fori=1 toNydo Loop over each single obs.

Xi oXx Compute perturb.; (Nx×Ne) HXi oH(X)i o) Ens. predicted obs; (1×Ne)

H Xi omean ofHXi o (1×1)

HXi oHXi oH Xi o (1×Ne) HP N11HXi oXTi o (1×Nx) H P HTHXi o

HXi oT

1×1 LocaliseHP; optional

FH P HT+σR,i o (1×1)

K 1FHP (1×Nx)

dyH Xi o (1×1)

α11+σ

FR (1×1)

α2α11 (1×1)

xai oxi of +Kd (Nx×1) Xi oXi o1α2KHX (Nx×Ne) Xai oXi o+xai o (Nx×Ne) end for

Algorithm 11SEnKF, see Section5.8

xf mean ofXf (Nx×1)

HXf H Xf

Ens. predicted obs.; (Ny×Ne)

HXf mean ofHXf (Ny×1)

HXf HXf HXf Ens. predicted pert.; (Ny×Ne)

Gen. obs. ensembleY (Ny×Ne)

DYHXf (Ny×Ne)

A N11HXf +D (Ny×Ne)

UVA Compute SVD; (Ny×Ne)

B1U−1 (Ny×Ne)

I1UTD (Ne×Ne)

I2−2I1 (Ne×Ne) I3 N11

HXfT

U (Ne×Ne)

wI3I2 (Ne×Ne)

XaXf+ N−11 Xfw (Nx×Ne)

Algorithm 12ESTKF, see Section5.9

xf mean ofXf (Nx×1)

Hxf H xf

Ens. predicted obs.; (Ny×1)

dyHxf (Ny×1)

HXf H Xf

(Ny×Ne) HL(HX)L (Ny×Ne1) B1R1HL (Ny×Ne1) InitialiseC1(N1)I (Ne1×Ne1) C2ρC1+(HL)TB1 (Ne1×Ne1) d1B1Td (Ne1×1) UUTC2 Compute EVD; (Ne1×Ne1) d2UTd1 (Ne1×1) forj=1 toN1do

d3(j)−1(j,j)d2(j) (Ne1×1) T1(:j)−1/2(j,j)U(:,j) (Ne1×Ne1) end for

wUd3 (Ne1×1)

T2T1UT (Ne1×Ne1) WT2AT (Ne1×Ne) Ww+W (Ne1×Ne)

WAAW (Ne×Ne)

XaXf+XfW (Nx×Ne)

Algorithm 13MLEF (using generalised non-linear conjugate-gradient), see Section5.10

C(Xf)THTR1HXf (Ne×Ne)

FI+C (Ne×Ne)

UUTF Compute EVD; (Ne×Ne)

FinvU−1UT (Ne×Ne) Finv2U1/2UT (Ne×Ne) GhalfXfFinv2 (Nx×Ne)

hxH(xf) (Ny×1)

foreach particlej=1, . . . ,Nedo

Xf(j)xf+Xf(j) (Nx×1) HX(j)H(Xf(j)) (Ny×1) Z(j)HX(j)hx (Ny×1) end for

dyhx (Ny×1)

ZRZTR−1 (Ne×Ny)

bZR d (Ne×1)

β0bTb (1×1)

ξ0 (Ne×1)

xaxf (Nx×1)

repeat

hxH(xa) (Ny×1)

foreach particlej=1, . . . ,Nedo

X(j)xa+Xf(j) (Nx×1) HX(j)H(X(j)) (Ny×1) Z(j)HX(j)hx (Ny×1) end for

dyhx (Ny×1)

ZRZTR−1 (Ne×p)

db1ZR d (Ne×1)

db2Finvξ (Ne×1) db2db1db2 (Ne×1)

β1dbT2db2 (1×1)

β=β10 (Fletcher-Reeves); (1×1) (Or use other formula forβ, e.g. Polak-Ribiere.)

bdb2+βb (Ne×1) ξξ+αb (Ne×1) xaxf+Ghalfξ (Nx×1)

β0β1 (1×1)

untilConvergence

hxH(xa) (Ny×1)

foreach particlej=1, . . . ,Ndo

X(j)xa+Xf(i) (Nx×1) HX(j)H(X(j)) (Ny×1) Z(j)HX(j)hx (Ny×1) end for

CZTR1Z (Ne×N)

FI+C (Ne×Ne)

UUTC Compute EVD; (Ne×Ne)

Finv2U1/2UT (Ne×Ne) XaXfFinv2 (Nx×1)

Algorithm 14ETPF, see Section6.3 diyH

xif

For each particle; (Ny×Ne)

wi=p(y|xif) (Ne×1)

J(T)Ne

i,jti j||xif xjf||2

Solve for minTJ(T)withti j 0 andNe

i ti j= N1eandNe j =wi (Ne2logNe)

xf mean ofXf (Nx×1)

Xf =Xf xfI (Nx×Ne) PXfXf T (Nx×Nx) ξN(0,h2P) (Nx×1) xajN

ixifti j +ξj (Nx×Ne)

Algorithm 15Relaxation step for EWPF and IEWPF algorithms (used in forecast step to nudge towards observations), see Section6.2.3

djyH xjf

For each particle; (Ny×Ne)

SolveRej=dj (Ny×Ne)

fjτ(m)Q1/2HTej (Nx×Ne) ξjN(0,I) Random forcing (Nx×Ne) xmj M

xmj1

+Q1/2(fj+ξj) (Nx×Ne) logwmj logwm−1j +fTj(fj+2ξj) (Nx×Ne)

Algorithm 16EWPF, see Section6.2.1

wr est← −logw(m−1) Weights from previous time steps (1×Ne)

0.0001/Ne Choose parameter; (1×1)

γU106 has to be small; (1×1)

γNπ2NxNx/2/2γ(1−)UNx (1×1)

k0.8 e.g. keep 80% particles; (1×1)

NkNek (1×1)

forj=1, . . . ,Nedo For each particle find max weights djyH

M(x(jm1))

(Ny×1) Solve

HQHT+R

ej=dj (Ny×1)

φjdTjej (1×1)

cjw(m−1)+0.5φj (1×1)

end for cˆ,idx

sor t(c) Sort max weights withidxholding sorted indices ofc;(Ne×1)

Cmax← ˆc(Nk) Find abs. max weight;(1×1) forj=1, . . . ,Nkdo For each remaining particle iidx(j) go through each kept particle; (1×1) KiQHTei (Ny×1)

ai12diTR−1HKi (1×1)

ridTiR1di (1×1)

bi12riCmax+wr est(i) (1×1) αi1+

1bi/ai (1×1)

β(1)Q1/2U(−γUI,UI)+N γN2Q

Random forcing (Nx×1)

xajM x(m−1)i

+αiKi+β (Nx×1) ifβwas from uniform distributionthen

wjwr est(i)+2i 2αi)ai+12ri (1×1) else

w1wr est(i)+i22αi)ai (1×1) w2w1+12ri

2−Nx/2 πNx/2

(1×1) w3w2γNγU−Nx(1 ) (1×1) wjw3exp

0.5β2i

(1×1) end if

end for

Resample to have full ensemble,Xa, of Neparticles using one of algorithms in Appendix1. Resample from subsetxaRNx×Nkand wR1×Nk. (Nx×Ne)

w N1e 1×Ne

Algorithm 17IEWPF, see Section6.2.2

wr est ← −logw(m1) Weights from previous time steps (1×Ne)

forj=1, . . . ,Nedo For each particle find max weights djyH

M(x(m−1)j )

(Ny×1) Solve

HQHT+R

ej=dj (Ny×1)

dbjdTjej (1×1)

cjwr est+0.5dbj (1×1)

end for

wtar getmin(c) Keep all particles; (1×1)

dmean ofdj (Ny×1)

ifPcan be calculated directlythen

P=(Q−1+HTR−1H)1 (Nx×Nx) ξiN(0,P) (Nx×Ne) elseuse e.g. ETKF algorithm:

˜ N(0,Q) Matrix of random vectors(Ne×Nx) CR−1H˜ (Ny×Ne) A(N1)I+

HQT

C (Ne×Ne)

DCTdj (Ne×1)

UUTA Compute EVD; (Ne×Ne)

w1UTD (Ne×1)

forj=1 toNedo Scale for each ens. member w2(j)w1(j)−1(j,j) (Ne×1) end for

wUw2 (Ne×1)

forj=1 toNedo Scale for each ens. member W1(j,:)

(j,j)U(j,:) (Ne×Ne) end for

WW1UT (Ne×Ne)

WW+w (Ne×Ne)

← ˜+ ˜W (Nx×Ne)

ξj=j (Nx×1) end if

forj=1, . . . ,Nedo for each particle

Solve

HQHT+R

ej=dj (Ny×1)

KjQHTej (Nx×1)

φj=dTjej (Nx×1)

xajM xm−1j

+Kj (Nx×1)

γjξTjξj (Nx×1)

ajφjwr estj +wtar get (1×1)

Solvej1jNxlogαj+aj=0 (1×1) xnjxaj+αjξj Nx×1 end for

Algorithm 18PFGR and NETF, see Section7.1

forj=1, . . . ,Nedo for each particle

wjp(y|xj)

ip(y|xi) (1×1)

end for

Wdi ag(w)wwT (Ne×Ne)

UUTW Compute EVD; (Ne×Ne)

T

NU1/2UT (Ne×Ne)

Prepare (Ne×Ne)

TT+w (Ne×Ne)

XaXfT (Nx×Ne)

Algorithm 19MMPF, see Section7.2

forj=1, . . . ,Nedo for each particle

wjp(y|xj)

ip(y|xi) (1×Ne)

end for

¯

xaXfw (Nx×1)

TTTdiag(w)wwT (Ne×Ne)

UUTTTT Compute EVD; (Ne×Ne)

BCTXf Compute SVD; (Nx×Ne)

ykpH(xk)(y|xk) Sample observations; (Ny×Ne)

fork=1, . . . ,Nedo Loop over sampled obs.

forj=1, . . . ,Nedo for each particle

˜

wj p(yk|xj) N

i=1p(yk|xi) (1×Ne)

end for

˜¯

xaXfw˜ (Nx×1)

T˜T˜Tdiag

˜ w

− ˜ww˜T (Ne×Ne) U˜˜U˜T← ˜TT˜T Compute EVD; (Ne×Ne) d

xk− ˜¯xa

(Nx×1)

d1BTd (1×Ne)

d1−1d1 Diagonal; (1×Ne)

d2Cd1 (1×Ne)

d2← ˜1/2d2 Diagonal˜; (1×Ne) d3← ˜UTd2 (1×Ne) d31/2d3 Diagonal; (1×Ne)

d4Ud3 (1×Ne)

xak= ¯xa+Xfd4 (Nx×1) end for

Algorithm 20Merging Particle Filter, see Section7.3

forj=1, . . . ,Nedo for each particle

wjp(y|xj)

ip(y|xi) (Ny×1)

end for

(X1a, . . .Xaq)qtimes resampled prior ensemble (q×Ne) Findαisuch that

iαi=1 and

iαi2=1 (q×q)

Xa

αiXia (q×Ne×Nx)

Algorithm 21Local PF Poterjoy, see Section9 forEach observationdo

˜

wiαp(y1|xi)+1α (1×Ne)

Resamplexki (Nx×1)

forEach grid pointjdo

ωiαρ(y1,xj,r)p(y1|xi)+1αρ(y1,xj,r)(1×Ne) xi

ωixi,j (1×1)

σ2

ωi(xi,jxi)2 (1×Ne)

cj N(1−αρ(xj,y1,r)) αρ(xj,y1,r)W˜

r1j σ

2 j 1

N1 N

i=1(xki,j− ¯xj+cj(xi,j− ¯xj))2 (1×Ne) r2jcjr1j

xi,aj= ¯xj+r1j(xki,j− ¯xj)+r2j(xi,j− ¯xj) (1×Ne) end for

end for

Algorithm 22Weightswi=p(y|xi)

jp(y|xj)for Gaussian obs. errors D← [y, . . . ,y] −H

Xf

(Ny×Ne)

D1R−1D (Ny×Ne)

wexp(−0.5DTD1) (Ny) ww/

jwj (Ny)