00001 /* 00002 * $Id$ 00003 * 00004 * Author: David Fournier 00005 * Copyright (c) 2008-2012 Regents of the University of California 00006 */ 00011 #include <fvar.hpp> 00012 00013 #ifdef __TURBOC__ 00014 #pragma hdrstop 00015 #include <iostream.h> 00016 #endif 00017 00018 #ifdef __ZTC__ 00019 #include <iostream.hpp> 00020 #endif 00021 00022 #include <math.h> 00023 00028 dvariable var(const dvar_vector& v) 00029 { 00030 dvariable tmp; 00031 RETURN_ARRAYS_INCREMENT(); 00032 tmp=norm(v)/sqrt(double(v.size())); 00033 dvariable tmp1; 00034 tmp1=mean(v); 00035 RETURN_ARRAYS_DECREMENT(); 00036 return(tmp*tmp-tmp1*tmp1); 00037 } 00038 00043 dvariable std_dev(const dvar_vector& v) 00044 { 00045 dvariable tmp; 00046 RETURN_ARRAYS_INCREMENT(); 00047 tmp=norm(v)/sqrt(double(v.size())); 00048 dvariable tmp1; 00049 tmp1=mean(v); 00050 RETURN_ARRAYS_DECREMENT(); 00051 return(sqrt(tmp*tmp-tmp1*tmp1)); 00052 } 00053 00058 dvariable mean(const dvar_vector& v) 00059 { 00060 dvariable tmp; 00061 RETURN_ARRAYS_INCREMENT(); 00062 tmp=sum(v)/double(v.size()); 00063 RETURN_ARRAYS_DECREMENT(); 00064 return(tmp); 00065 }
Generated on Tue Mar 8 2016 19:51:33 for ADMB Documentation by 1.8.0 |