[15393] | 1 | Index: ../trunk-jpl/src/m/miscellaneous/prctile_issm.m
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/m/miscellaneous/prctile_issm.m (revision 14325)
|
---|
| 4 | +++ ../trunk-jpl/src/m/miscellaneous/prctile_issm.m (revision 14326)
|
---|
| 5 | @@ -35,7 +35,7 @@
|
---|
| 6 |
|
---|
| 7 | % check for any NaN in any columns
|
---|
| 8 |
|
---|
| 9 | - if ~any(isnan(x))
|
---|
| 10 | + if ~any(any((isnan(x))))
|
---|
| 11 | x=sort(x,1);
|
---|
| 12 | n=size(x,1);
|
---|
| 13 |
|
---|
| 14 | Index: ../trunk-jpl/src/m/miscellaneous/normfit_issm.m
|
---|
| 15 | ===================================================================
|
---|
| 16 | --- ../trunk-jpl/src/m/miscellaneous/normfit_issm.m (revision 14325)
|
---|
| 17 | +++ ../trunk-jpl/src/m/miscellaneous/normfit_issm.m (revision 14326)
|
---|
| 18 | @@ -7,47 +7,54 @@
|
---|
| 19 | alpha=0.05;
|
---|
| 20 | end
|
---|
| 21 |
|
---|
| 22 | -% remove any NaN
|
---|
| 23 | +% check for any NaN in any columns
|
---|
| 24 |
|
---|
| 25 | - if find(isnan(x))
|
---|
| 26 | - muhat =zeros(1,size(x,2));
|
---|
| 27 | - sigmahat=zeros(1,size(x,2));
|
---|
| 28 | - muci =zeros(2,size(x,2));
|
---|
| 29 | - sigmaci =zeros(2,size(x,2));
|
---|
| 30 | - for j=1:size(x,2)
|
---|
| 31 | - [muhat(j),sigmahat(j),muci(:,j),sigmaci(:,j)]=normfit_issm(x(~isnan(x(:,j)),j),alpha);
|
---|
| 32 | - end
|
---|
| 33 | - return
|
---|
| 34 | - end
|
---|
| 35 | + if ~any(any((isnan(x))))
|
---|
| 36 |
|
---|
| 37 | % explicitly calculate the moments
|
---|
| 38 |
|
---|
| 39 | - muhat =mean(x);
|
---|
| 40 | - sigmahat=std(x);
|
---|
| 41 | + muhat =mean(x);
|
---|
| 42 | + sigmahat=std(x);
|
---|
| 43 |
|
---|
| 44 | - if (nargout>2)
|
---|
| 45 | - prob=1.-alpha/2.;
|
---|
| 46 | + if (nargout>2)
|
---|
| 47 | + prob=1.-alpha/2.;
|
---|
| 48 |
|
---|
| 49 | - if (size(x,1) == 1)
|
---|
| 50 | - % operate like matlab normfit, mean, std, etc.
|
---|
| 51 | - n=length(x);
|
---|
| 52 | - else
|
---|
| 53 | - n=size(x,1);
|
---|
| 54 | + if (size(x,1) == 1)
|
---|
| 55 | + % operate like matlab normfit, mean, std, etc.
|
---|
| 56 | + n=length(x);
|
---|
| 57 | + else
|
---|
| 58 | + n=size(x,1);
|
---|
| 59 | + end
|
---|
| 60 | +
|
---|
| 61 | + muci =zeros(2,length(muhat ));
|
---|
| 62 | + sigmaci =zeros(2,length(sigmahat));
|
---|
| 63 | +
|
---|
| 64 | + try
|
---|
| 65 | + muci(1,:) =muhat-tinv(prob,n-1)*sigmahat/sqrt(n);
|
---|
| 66 | + muci(2,:) =muhat+tinv(prob,n-1)*sigmahat/sqrt(n);
|
---|
| 67 | + sigmaci(1,:)=sigmahat*sqrt((n-1)/chi2inv(prob ,n-1));
|
---|
| 68 | + sigmaci(2,:)=sigmahat*sqrt((n-1)/chi2inv(1.-prob,n-1));
|
---|
| 69 | + catch me
|
---|
| 70 | + muci(1,:) =muhat;
|
---|
| 71 | + muci(2,:) =muhat;
|
---|
| 72 | + sigmaci(1,:)=sigmahat;
|
---|
| 73 | + sigmaci(2,:)=sigmahat;
|
---|
| 74 | + end
|
---|
| 75 | end
|
---|
| 76 |
|
---|
| 77 | - muci =zeros(2,length(muhat ));
|
---|
| 78 | - sigmaci =zeros(2,length(sigmahat));
|
---|
| 79 | + else
|
---|
| 80 |
|
---|
| 81 | - try
|
---|
| 82 | - muci(1,:) =muhat-tinv(prob,n-1)*sigmahat/sqrt(n);
|
---|
| 83 | - muci(2,:) =muhat+tinv(prob,n-1)*sigmahat/sqrt(n);
|
---|
| 84 | - sigmaci(1,:)=sigmahat*sqrt((n-1)/chi2inv(prob ,n-1));
|
---|
| 85 | - sigmaci(2,:)=sigmahat*sqrt((n-1)/chi2inv(1.-prob,n-1));
|
---|
| 86 | - catch me
|
---|
| 87 | - muci(1,:) =muhat;
|
---|
| 88 | - muci(2,:) =muhat;
|
---|
| 89 | - sigmaci(1,:)=sigmahat;
|
---|
| 90 | - sigmaci(2,:)=sigmahat;
|
---|
| 91 | +% must loop over columns, since number of elements could be different
|
---|
| 92 | +
|
---|
| 93 | + muhat =zeros(1,size(x,2));
|
---|
| 94 | + sigmahat=zeros(1,size(x,2));
|
---|
| 95 | + muci =zeros(2,size(x,2));
|
---|
| 96 | + sigmaci =zeros(2,size(x,2));
|
---|
| 97 | +
|
---|
| 98 | +% remove any NaN and recursively call column
|
---|
| 99 | +
|
---|
| 100 | + for j=1:size(x,2)
|
---|
| 101 | + [muhat(j),sigmahat(j),muci(:,j),sigmaci(:,j)]=normfit_issm(x(~isnan(x(:,j)),j),alpha);
|
---|
| 102 | end
|
---|
| 103 | end
|
---|
| 104 |
|
---|