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

📄 xmoment.c

📁 Numerical Recipes Software 提供的算法子程序集
💻 C
字号:
/* Driver for routine moment */

#include <stdio.h>
#include <math.h>
#define NRANSI
#include "nr.h"
#include "nrutil.h"

#define PI 3.14159265
#define NPTS 5000
#define NBIN 100
#define NPPNB (NPTS+NBIN)

int main(void)
{
	int i=0,k,nlim;
	float adev,ave,curt,sdev,skew,vrnce,x,*data;

	data=vector(1,NPPNB);
	for (x=PI/NBIN;x<=PI;x+=PI/NBIN) {
		nlim=(int) (0.5+sin(x)*PI/2.0*NPTS/NBIN);
		for (k=1;k<=nlim;k++) data[++i]=x;
	}
	printf("moments of a sinusoidal distribution\n\n");
	moment(data,i,&ave,&adev,&sdev,&vrnce,&skew,&curt);
	printf("%39s %11s\n\n","calculated","expected");
	printf("%s %17s %12.4f %12.4f\n","Mean :"," ",ave,PI/2.0);
	printf("%s %4s %12.4f %12.4f\n",
		"Average Deviation :"," ",adev,(PI/2.0)-1.0);
	printf("%s %3s %12.4f %12.4f\n",
		"Standard Deviation :"," ",sdev,0.683667);
	printf("%s %13s %12.4f %12.4f\n",
		"Variance :"," ",vrnce,0.467401);
	printf("%s %13s %12.4f %12.4f\n",
		"Skewness :"," ",skew,0.0);
	printf("%s %13s %12.4f %12.4f\n",
		"Kurtosis :"," ",curt,-0.806249);
	free_vector(data,1,NPPNB);
	return 0;
}
#undef NRANSI
/* (C) Copr. 1986-92 Numerical Recipes Software . */

⌨️ 快捷键说明

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