% Example.
% Recover density from put option quotes:
load spectralExampleData
% compute density with 'optimal' level of spectral cutoff N.
result1 = spectralrecovery(X,bid,ask,F,r,tau)
% compute density with double that value
result2 = spectralrecovery(X,bid,ask,F,r,tau,2*result1.N)
subplot(2,1,1)
plot(X,[bid ask],'k.',result1.X,result1.prices,result2.X,result2.prices);
axis([30 70 0 20])
legend( 'bid','ask', ...
['model with spectral cutoff N=' num2str(result1.N)], ...
['model with spectral cutoff N=' num2str(result2.N)], ...
'Location','SouthEast')
title('recovered prices')
subplot(2,1,2)
plot(result1.X,result1.densityX,'k',result2.X,result2.densityX,'b')
axis([30 70 0 0.1])
legend( ['implied density with spectral cutoff N=' num2str(result1.N)], ...
['implied density with spectral cutoff N=' num2str(result2.N)])