function [a,b,dz,w]=estdrift(c,g,dt,z)
n=length(z)-1;
z1=z(1:n);
dz=diff(z);
m2 = dt*c^2*(z1.^(2*g)).*(1+.5*c^2*g^2*dt*z1.^(2*g-2));
 w = 1./m2;
p=wreg(z1,dz,w);
b=(log(1+p(2)))/dt;
a = p(1)*b/p(2);
