function [hn,ln,on,cn]=bootnorm(h,l,o,c)
%generates normal high low open close data corresponding to the input data with the increments
%in the same order.
n=length(c);
x1=c-o;
m1=mean(x1);
s1=var(x1);
[x,i1]=sort(x1);
x2=o(2:n)-c(1:n-1);
m2=mean(x2);
s2=var(x2);
[x,i2]=sort(x2);
d1=sort(normrnd(m1,sqrt(s1),n,1));
n1=sort(normrnd(m2,sqrt(s2),n-1,1));
d1=d1(i1);
n1=n1(i2);
on=o(1)+cumsum([0 ; d1(1:n-1)+n1]);
cn=on+d1;
Z1=(h-o).*(h-c);
m3=mean(Z1);
Z2=sort(exprnd(m3,n,1))
[x,i3]=sort(Z1);
Z2=Z2(i3);
hn=.5*(on+cn+sqrt((on-cn).^2 + 4*Z2));
Z1=(l-o).*(l-c);
m3=mean(Z1);
Z2=sort(exprnd(m3,n,1))
[x,i3]=sort(Z1);
Z2=Z2(i3);
hn=.5*(on+cn-sqrt((on-cn).^2 + 4*Z2));
