function marketmodel(startprice,years,meanint,volatility)
% The input parameters are:
%  startprice = Price per share on the first day of trading
%  years      = Duration of model in years of 256 trading days each.
%  meanint    = Mean growth (over a large ensemble), as an APR.
%  volatility = How crazy the market should be. 1 is fairly mild, producing.
%               few years of loss. Should probably increase with meanint.

fN = 256*years; %I think the stock market normally has 252 trading days per year.
k = 0:fN;
ps = 1./(1+k.^2);
signal = volatility*fN*randsig(ps)/100;
sigsize = numel(signal)
fluctuations = exp(signal);
fluctuations /= fluctuations(1);
prices = startprice*fluctuations;

growthtrend = exp( (0:(fN-1))/(fN-1) * years*log(1+meanint/100) );
prices .*= growthtrend;

figure(2)
semilogy((1:fN)/256,prices)
figure(1)
plot((1:fN)/256,prices)
