= speye(nd(2));

% generate outliers by replacing a fraction p of the data with
% random normal (0, a)
s = RandStream.create('mt19937ar','seed',seed);
I = randi(s,prod(nd),floor(p*prod(nd)),1);
D(I) = a*randn(s,size(I));

D = distributed(vec(D));

% inversion
params.misfit  = fh1;
params.src_est = fh2;

fh = @(x)JI_src(x,Q,D,[1:nd(2)],model,params);

options.itermax = maxiter;
options.fid     = fopen('iter.log','w');

mn = mylbfgs(fh,m0,options);

% final evaluation
[fn,gn,wn] = fh(mn);

% write results
rsf