n = setup->caldacs[cdac].maxdata+1;
memset(l,0,sizeof(*l));
- step=n/256;
+ step=n/16;
if(step<1)step=1;
l->n=0;
update_caldac( setup, cdac, orig );
- l->yerr=sum_err/sum_err_count;
+ l->yerr=sum_err/sqrt(sum_err_count);
l->dx=step;
l->x0=0;
update_caldac( setup, cdac, orig );
- l->yerr=sum_err/sum_err_count;
+ l->yerr=sum_err/sqrt(sum_err_count);
l->dx=1;
l->x0=orig-fine_size;
lsampl_t *data;
int n,i,ret;
- double a,x,s,s2;
+ double x,s,s2;
n=1<<sv->order;
s=0;
s2=0;
- a=comedi_to_phys(data[0],sv->rng,sv->maxdata);
- for(i=0;i<n;i++){
- x=comedi_to_phys(data[i],sv->rng,sv->maxdata);
- s+=x-a;
- s2+=(x-a)*(x-a);
+ for(i = 0; i < n; i++){
+ x = comedi_to_phys(data[i], sv->rng, sv->maxdata);
+ s += x;
+ s2 += x * x;
}
- sv->average=a+s/n;
- sv->stddev=sqrt(n*s2-s*s)/n;
- sv->error=sv->stddev/sqrt(n);
+ s /= n;
+ s2 /= n;
+ sv->average=s;
+ sv->stddev=sqrt( ( ( n + 1 ) / n ) * ( s2 - s * s ) );
+ sv->error=sv->stddev / sqrt( n );
ret=n;
{
lsampl_t *data;
int n,i,ret;
- double a,x,s,s2;
+ double x,s,s2;
n=1<<order;
s=0;
s2=0;
- a=comedi_to_phys(data[0],sv->rng,sv->maxdata);
- for(i=0;i<n;i++){
- x=comedi_to_phys(data[i],sv->rng,sv->maxdata);
- s+=x-a;
- s2+=(x-a)*(x-a);
+ for(i = 0; i < n; i++){
+ x = comedi_to_phys(data[i], sv->rng, sv->maxdata);
+ s += x;
+ s2 += x * x;
}
- sv->average=a+s/n;
- sv->stddev=sqrt(n*s2-s*s)/n;
- sv->error=sv->stddev/sqrt(n);
+ s /= n;
+ s2 /= n;
+ sv->average = s;
+ sv->stddev=sqrt( ( ( n + 1 ) / n ) * ( s2 - s * s ) );
+ sv->error=sv->stddev / sqrt( n );
ret=n;