diff m-toolbox/classes/+utils/@math/fitPrior.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@math/fitPrior.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,15 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%   Function fitpriors fits the pdf computed from a pest object.          %
+%   It returns matrix (# of params x 3) with the mean, sigma and          %
+%   normalization constant for each parameter at each column. -Nikos-     %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function params = fitPrior(prior,nparam,chain,bins) 
+params = [];
+
+    for ii=1:nparam
+    x = linspace(min(prior(:,2*ii-1)),max(prior(:,2*ii-1)),bins);
+    y = normpdf(x,mean(chain(:,ii)),std(chain(:,ii)));  
+    s=sum(y);
+    params(ii,:) = [mean(chain(:,ii)) std(chain(:,ii)) s];
+    end
+end
\ No newline at end of file