⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stat.h

📁 使用R语言的马尔科夫链蒙特卡洛模拟(MCMC)源代码程序。
💻 H
📖 第 1 页 / 共 2 页
字号:
    };  }     /*! 	* \brief Calculate the variance of a Matrix	*	* This function calculates the variance of a matrix.	*	* \param A The matrix whose variance is of interest.	*  * \see var(cons Matrix<T,PO,PS> &A, T mu)	* \see varc(const Matrix<T,PO,PS> &A)	* \see sd(const Matrix<T,PO,PS> &A)	* \see mean(const Matrix<T,PO,PS> &A)	*/  template <typename T, matrix_order PO, matrix_style PS>  T  var (const Matrix<T,PO,PS> &A)  {    return var(A, mean(A));  }  /* Calculate the variances of each column of a Matrix. */    /*! 	* \brief Calculate the variance of each column of a Matrix	*	* This function calculates the variance of each column of a matrix.	*	* \param A The matrix whose variances are of interest.	*	* \see var(const Matrix<T,PO,PS> &A)  * \see var(cons Matrix<T,PO,PS> &A, T mu)	* \see sdc(const Matrix<T,PO,PS> &A)	* \see meanc(const Matrix<T,PO,PS> &A)	*/	  SCYTHE_STATMETH_COL(var) /*! 	* \brief Calculate the variance of a Matrix	*	* This function calculates the variance of a matrix when the mean is  * already known.	*	* \param A The matrix whose variance is of interest.  * \param mu The mean of the values in the matrix.	*  * \see var(cons Matrix<T,PO,PS> &A)	* \see varc(const Matrix<T,PO,PS> &A)	* \see sd(const Matrix<T,PO,PS> &A)	* \see mean(const Matrix<T,PO,PS> &A)	*/  template <typename T, matrix_order PO, matrix_style PS>  T  var (const Matrix<T,PO,PS> &A, T mu)  {    return std::accumulate(A.begin_f(), A.end_f(), (T) 0,                          var_step<T, uint> (mu, A.size() - 1, 2));  }    /* Calculate the standard deviation of a Matrix (not std cause of namespace std:: */    /*! 	* \brief Calculate the standard deviation of a Matrix	*	* This function calculates the standard deviation of a matrix by 	* taking the square root of the matrix's variance. 		*	* \param A The matrix whose standard deviation is of interest.	*  * \see sd(const Matrix<T,PO,PS) &A, T mu)	* \see sdc(const Matrix<T,PO,PS> &A)	* \see variance(const Matrix<T,PO,PS> &A)	*/	  template <typename T, matrix_order PO, matrix_style PS>  T  sd (const Matrix<T,PO,PS> &A)  {    return std::sqrt(var(A));  }    /* Calculate the standard deviation of each column of a Matrix */   /*! 	* \brief Calculate the standard deviation of each column of a Matrix	*	* This function calculates the standard deviation of each column of a matrix by 	* taking the square root of each column's variance. 		*	* \param A The matrix whose standard deviations are of interest.	*	* \see sd(const Matrix<T,PO,PS> &A)	* \see variancec(const Matrix<T,PO,PS> &A)	*/	  SCYTHE_STATMETH_COL(sd)  /*! 	* \brief Calculate the standard deviation of a Matrix	*	* This function calculates the standard deviation of a matrix  * when the matrix's mean is already known.	*	* \param A The matrix whose standard deviation is of interest.  * \param mu The matrix mean.	*  * \see sd(const Matrix<T,PO,PS) &A)	* \see sdc(const Matrix<T,PO,PS> &A)	* \see variance(const Matrix<T,PO,PS> &A)	*/	  template <typename T, matrix_order PO, matrix_style PS>  T  sd (const Matrix<T,PO,PS> &A, T mu)  {    return std::sqrt(var(A, mu));  }  /* Calculate the skew of a Matrix */  /*! 	 * \brief Calculate the skew of a Matrix	 *	 * This function calculates the skew of a matrix.	 *	 * \param A The matrix whose skew is of interest.	 *	 * \see skewc(const Matrix<T,PO,PS> &A)	 * \see kurtosis(const Matrix<T,PO,PS> &A)	 */  template <typename T, matrix_order PO, matrix_style PS>  T  skew (const Matrix<T,PO,PS> &A)  {    T mu = mean(A);    T sde = sd(A, mu);    return std::accumulate(A.begin_f(), A.end_f(), (T) 0,               var_step<T, T> (mu, A.size() * std::pow(sde, 3), 3));  }  /* Calculate the skew of each column of a Matrix. */     /*! 	* \brief Calculate the skew of each column of a Matrix	*	* This function calculates the skew of each column of a matrix.	*	* \param A The matrix whose skews are of interest.	*	* \see skew(const Matrix<T,PO,PS> &A)	* \see kurtosisc(const Matrix<T,PO,PS> &A)	*/  SCYTHE_STATMETH_COL(skew)    /* Calculate the kurtosis of a Matrix */       /*! 	* \brief Calculate the kurtosis of a Matrix	*	* This function calculates the kurtosis of a matrix.	*	* \param A The matrix whose kurtosis is of interest.	*	* \see skew(const Matrix<T,PO,PS> &A)	* \see kurtosisc(const Matrix<T,PO,PS> &A)	*/  template <typename T, matrix_order PO, matrix_style PS>  T  kurtosis (const Matrix<T,PO,PS> &A)  {    T mu = mean(A);    T sde = sd(A, mu);    return (std::accumulate(A.begin_f(), A.end_f(), (T) 0,               var_step<T, T> (mu, A.size() * std::pow(sde, 4), 4))            - 3);  }    /* Calculate the kurtosis of each column of a Matrix. */     /*! 	* \brief Calculate the kurtosis of each column of a Matrix	*	* This function calculates the kurtosis of each column of a matrix.	*	* \param A The matrix whose kurtoses are of interest.	*	* \see skewc(const Matrix<T,PO,PS> &A)	* \see kurtosis(const Matrix<T,PO,PS> &A)	*/  SCYTHE_STATMETH_COL(kurtosis)  /* Calculates the maximum element in a Matrix */  /*! 	* \brief Calculate the maximum element in a Matrix	*	* This function identifies the maximum element in a matrix.	*	* \param A The matrix whose maximum element is of interest.	*	* \see min(const Matrix<T,PO,PS> &A)	* \see maxc (const Matrix<T,PO,PS> &A)	*/	  template <typename T, matrix_order PO, matrix_style PS>  T  max (const Matrix<T,PO,PS> &A)  {    return *(max_element(A.begin_f(), A.end_f()));  }   /*! 	* \brief Calculate the maximum of each column of a Matrix	*	* This function identifies the maximum of each column in a matrix.	*	* \param A The matrix whose maximae are of interest.	*	* \see max(const Matrix<T,PO,PS> &A)	* \see minc(const Matrix<T,PO,PS> &A)	*/    SCYTHE_STATMETH_COL(max)  /* Calculates the minimum element in a Matrix */  	/*! 	* \brief Calculate the maximum element in a Matrix	*	* This function identifies the maximum element in a matrix.	*	* \param A The matrix whose maximum element is of interest.	*	* \see max(const Matrix<T,PO,PS> &A)	* \see minc(const Matrix<T,PO,PS> &A)	*/  template <typename T, matrix_order PO, matrix_style PS>  T  min (const Matrix<T,PO,PS> &A)  {    return *(min_element(A.begin_f(), A.end_f()));  }     /*! 	* \brief Calculate the minimum of each column of a Matrix	*	* This function identifies the minimum of each column in a matrix.	*	* \param A The matrix whose minimae are of interest.	*	* \see min(const Matrix<T,PO,PS> &A)	* \see maxc(const Matrix<T,PO,PS> &A)	*/    SCYTHE_STATMETH_COL(min)  /* Find the index of the max element */  	/*! 	* \brief Calculate the index of the maximum element in a Matrix	*	* This function identifies the index of the maximum element in a matrix.	*	* \param A The matrix whose maximum element indices are of interest.	*	* \see minind(const Matrix<T,PO,PS> &A)	* \see max(const Matrix<T,PO,PS> &A)	* \see maxindc(const Matrix<T,PO,PS> &A)	*/  template <typename T, matrix_order PO, matrix_style PS>  unsigned int  maxind (const Matrix<T,PO,PS> &A)  {    return (max_element(A.begin_f(), A.end_f())).get_index();  }     /*! 	* \brief Calculate the index of the maximum for each column of a Matrix	*	* This function identifies the index of the maximum for each column of a Matrix.	*	* \param A The matrix whose maximum indices are of interest.	*	* \see maxc(const Matrix<T,PO,PS> &A)	* \see minindc(const Matrix<T,PO,PS> &A)	*/  SCYTHE_STATMETH_COL(maxind)    /* Find the index of the min element */    /*! 	* \brief Calculate the index of the minimum element in a Matrix	*	* This function identifies the index of the minimum element in a matrix.	*	* \param A The matrix whose minimum element indices are of interest.	*	* \see maxind(const Matrix<T,PO,PS> &A)	* \see min(const Matrix<T,PO,PS> &A)	* \see minindc(const Matrix <T> &A)	*/  template <typename T, matrix_order PO, matrix_style PS>  unsigned int  minind (const Matrix<T,PO,PS> &A)  {    return (min_element(A.begin_f(), A.end_f())).get_index();  }    /*! 	* \brief Calculate the index of the minimum for each column of a Matrix	*	* This function identifies the index of the minimum for each column of a Matrix.	*	* \param A The matrix whose minimum indices are of interest.	*	* \see minc(const Matrix<T,PO,PS> &A)	* \see maxindc(const Matrix<T,PO,PS> &A)	*/  SCYTHE_STATMETH_COL(minind)} // end namespace scythe#endif /* SCYTHE_STAT_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -