资源简介
能对气候水文等相关数据序列进行突变检验(fortran)和趋势分析(C)。

代码片段和文件信息
//This program calculates Mann-Kendall parameters for trend test.
//Condition: x is ordered from low to high.
//These parameters are:
// n-1 n
// S=sum (sum (sgn(yj-yi));
// i=1 j=i+1
// n: Sample size;
//sigma = sqrt(n(n-1)(2n+5)/18)
// Zs =(S-1)/sigma S>0
// Zs = 0 S=0
// Zs = (S+1)/sigma S<0
// Get the critical value of standard normal distribution with a probability of exceedance of alph/2.
// Get the Mann-Kendal slope
#include
#include
#include
#define ELEM_SWAP(ab) { register float t=(a);(a)=(b);(b)=t; }
double median(double *arr int n) ;
double mk_magnitude(float *x double *y int n);
main (int argc char *argv[]) {
int nrows i j k s positive negative equal;
float *x temp tau sigma zs;
double *y slope;
float norm[6]={0.8421.2821.6451.9602.3262.576};
float slevel[6]={0.600.800.900.950.980.99}level_out;
FILE *fi *fo;
if(argc !=3) {
printf(“USAGE %s input output\n“ argv[0]);
exit(0);
}
if((fi = fopen(argv[1] “r“)) == NULL) {
printf(“Cannot open input file.\n“);
exit(0);
}
if((fo = fopen(argv[2] “w“)) == NULL) {
printf(“Cannot create output file.\n“);
exit(0);
}
nrows = GetLineNumbers(fi);
printf(“Row number is %d\n“ nrows);
x= (float *) calloc(nrows sizeof(float));
y = (double *) calloc(nrows sizeof(double));
for(i=0; i fscanf(fi “%f %lf“ &x[i] &y[i]);
// printf(“%f %lf\n“ x[i] y[i]);
}
positive = negative = equal=0;
for(i=0; i temp = y[i];
for(j=i+1; j if(temp == y[j]) equal++;
if(temp < y[j]) positive++;
if(temp > y[j]) negative++;
}
}
s= positive + negative *(-1);
tau = s/ (nrows * (nrows-1) /2);
sigma = sqrt(nrows * (nrows-1) * (2*nrows+5)/18);
if(s>0) zs= (s-1)/sigma;
if(s==0) zs=0;
if(s<0) zs= (s+1)/sigma;
level_out=-9;
for(i=0;i<6;i++) {
if(fabs(zs)>=norm[i]) {
level_out=slevel[i];
}
}
// if(level_out != -9) {
slope= mk_magnitude(xy nrows);
printf(“done slope\n“);
// }
// else slope =0;
printf(“zs=%f s=%d positive= %d negative=%d equal=%d level_out=%f slope=%lf\n“ zs s positive negative equal level_out slope);
fprintf(fo “Zs=%f S=%d N=%d Sigma=%f\n“ zs s nrows sigma);
fprintf(fo “Positive=%d Negative=%d Equal=%f\n“ positive negative equal);
fprintf(fo “level_out=%f slope=%lf\n“ level_out slope);
}
int GetLineNumbers(FILE *fp) {
int nlines=0;
char ch;
long start;
start = ftell(fp);
while((ch=fgetc(fp)) != EOF) if(ch==‘\n‘) nlines++;
fseek(fp start SEEK_SET);
return nlines;
}
double mk_magnitude(float *x double *y int n)
{
double *D;
double b;
int i j l;
int nd;
/* Calculate trend magnitude */
nd = (n*(n-1)/2);
D = (double*)calloc(ndsizeof(double));
l=0;
for (i=0;i<(n-1);i++) {
for (j=(i+1);j D[l] = (y[i]-y[j])/(x[i]-x[j]);
l++;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4502 2010-12-07 16:47 MK\Mann_Kendall_parameters.c
文件 1460 2010-09-08 17:00 MK\MK.FOR
目录 0 2010-12-27 11:29 MK
----------- --------- ---------- ----- ----
5962 3
- 上一篇:hspice语法手册.pdf
- 下一篇:某书店书刊出租和零售管理系统数据库系统设计
相关资源
- Apolipoprotein E4 Impairs in vivo Hippocampal
- altium适用的m.2接口封装, MKey的插头和
- 计算机控制系统:原理与设计_第3版
- 利用FFmpeg将mkv视频转换为H.264
- 三维时空,可积系统和KdV / mKdV层次结
- 深思写锁586、582全国版更新2018.09.20含
- 最好用的电子狗模拟器multkey Mk19.1.9
- mk5tew.doc
- MKIII 双频测深仪
- mks安装及使用规范
- CHEMKIN软件手册
- Kintex MK7325FA开发板硬件使用手册2018
- 米酷影视源码MKCMS5.0影视源码
- MKVtoolnix 4.9.1 + MKVExtractGUI 2.2.2.5
- kmv文件解码器
- Introduction to Statistical Machine Learning B
- MKcms5.0影视源码完美修复版电脑手机自
- mkfs.jffs2
- mpu6050模块程序(山外K60库)
- mkcert v1.4.1
- 全国 各省 广联达
- MK检验介绍PPT
- CentOsUbuntu环境mkfontscalemkfontdir命令rp
- Cohda MK5 开发资料
- chemkin_pro docs.rar
- B250MKYLIN.bin
- MKL——最全说明文档
- numpy-1.18.3+mkl-cp38-cp38-win_amd64.whl
- numpy-1.16.2+mkl-cp37-cp37m-win_amd64.whl
- MK60DN512ZVLQ10完整芯片资料
评论
共有 条评论