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

📄 ocn_g01.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 2 页
字号:
/*------------------------------------------------------------------------------*
 * File Name: OCN_g01.h															*
 * Creation: SDB 5/22/2001														*
 * Purpose: Origin C Header for NAG functions									*
 * Copyright (c) OriginLab Corp.	2001										*
 * All Rights Reserved															*
 * 																				*
 * Modification Log:															*
 * TCZ 06/10/2001, put_some_test_results_here								    *
 *------------------------------------------------------------------------------*/

#ifndef _O_NAG_G01_H
#define _O_NAG_G01_H

//#importdll "ONAG" // NAG DLL prepared by OriginLab
#pragma dll(ONAG)	
#include <NAG\nag_types.h>


/*	begin proto */

/**	g01aac
		calculates the mean, standard deviation, coefficients of skewness
		and kurtosis, and the maximum and minimum values of a set of
		ungrouped data.  Weighting may be used.

Example1:
	Read a set of data with 10 unweighted data values from worksheet "Data1", 
	calculates the mean, standard deviation, coeffieients of skewness and kurtosis, 
	and the maximum and minimum values.
	
	double xsd,xskew, xkurt, wsum, xmean, xmax, xmin;
	double * wt;
	int sucess, weight, nvalid = 10;
	wt = NULL;
	Dataset xx("data1",0);
	//Dataset cannot be used as a parameter, but vector can.
	vector x = xx;
	sucess = nag_summary_stats_1var(nvalid, x, wt, &nvalid, &xmean, &xsd, &xskew,
			&xkurt, &xmin, &xmax, &wsum);
	 
Example2:
	In the example, there is one set of data with 24 unweighted data values.

void  test_nag_summary_stats_1var()
{
	double xsd,xskew, xkurt, wsum, xmean, xmax, xmin;
	double * wt;
	int sucess,i, weight, j, nvalid = 24;
	double x[24] = {193.0, 215.0, 112.0, 161.0, 92.0, 140.0, 38.0, 33.3, 279.0,
					249.0, 473.0, 339.0, 60.0, 130.0, 20.0, 50.0, 257.0, 284.0,
					447.0, 52.0, 67.0, 61.0, 150.0, 2220.0};	
	wt = NULL;
	
	sucess = nag_summary_stats_1var(nvalid, x, wt, &nvalid, &xmean, &xsd, &xskew,
			&xkurt, &xmin, &xmax, &wsum);
   	
   	printf("Number of cases is %d\n", nvalid);
   	printf("And there is no weight\n");
   	printf("The input is following : x=\n");
   	
   	for(i=0; i<24; i++)
	{
		printf("%10.1f", x[i]);
		if((i+1)%10 == 0)
		printf("\n");
	}
	
	printf("\nsucess is%d\n", sucess);	
	if(sucess == 0)
	{
		printf("\nsucessfully call of the nag_summary_stats_1var function\n");
		printf("the output is following:\n");
		printf("No of valid cases         %10d\n", nvalid);
		printf("mean                      %10.1f\n", xmean);
		printf("std devn                  %10.1f\n", xsd);
		printf("Skewness                  %10.1f\n", xskew);
		printf("Kurtosis                  %10.1f\n", xkurt);	
		printf("Minimun                   %10.1f\n", xmin);
		printf("Maximum                   %10.1f\n", xmax);
		printf("Sum of weights            %10.1f\n", wsum);
	}
	else
	{
		printf(" \n There are some problems.");
	}
}

	The output is following:
	
	No. of valid cases                24
	mean                           255.1
	std devn                       437.4
	Skewness                         3.9
	Kurtosis                        14.7
	Minimun                         20.0
	Maximum                       2220.0
	Sum of weights                  24.0	

Return:
	The function returns NAG error code or 0 if no error.
	
	NE_INT_ARG_LE(12):	On entry, n must not be less than or equal to 0: n =value.
	NE_CASES_ONE(401): The number of valid cases is one. In this case,standard deviation and coeficients of skewness and of kurtosis cannot be calculated.
	NE_CASES_ZERO(400): The number of valid cases is zero.
	NE_REAL_ARG_LT(5): On entry, wt [value] must not be less than 0.0: wt [value ]=value

	success is 0.
	successfully call of the nag_summary_stats_1var function.
	
*/

int nag_summary_stats_1var(
	int n, // the number of observations
	const double x[], // the sample of observations, x[i]. i = 0,1,2 ..., n
	const double wt[], // the weight, can be NULL is not specified 
	int* nvalid, // the number of valid observations, (n) minus number of missing values
	double *xmean, 
	double *xsd,
	double *xskew = NULL,
	double *xkurt = NULL,
	double *xmin = NULL,
	double *xmax = NULL,
	double *wsum = NULL // the sum of weights, equals (n) if no weight is specified
);	// Mean, standard deviation, skewness, kurtosis etc, one variable, from raw data.


/**	g01aec
		constructs a frequency distribution of a variable, according to either
		user-supplied, or routine-calculated class boundary values.
Example1:
	Assume we have two worksheets, "Data1"'s datatype is double, "Data2"'s datatype
	is integer.  We have two columns in "Data1", the first column contains 70 data, 
	and we have to put the result to the second column of "Data1" and first column 
	of "Data2".
	
	double  xmax, xmin;
	int success, num_class = 7, iclass = 0, n = 70;
	Nag_ClassBoundary iclass_enum;
	iclass_enum = Nag_ClassBoundaryComp;
	Dataset aa("data1",0); 
	aa.SetSize(n);
	Dataset cc("data1",1);
	cc.SetSize( 7 );
	Dataset difreq("data2",0);
	difreq.SetSize( 7 );
	vector a = aa, c = cc;
	vector<int> ifreq = difreq;
	success = nag_frequency_table(n, a, num_class, iclass_enum, c, ifreq, &xmin, &xmax );
	//write the result back to the worksheets.
	difreq = ifreq;
	cc = c;
			
Example2:
	In this example, there are 70 observations.
	
void  test_nag_frequency_table()
{
	double  xmax, xmin;
	double c[7];
	int sucess, i, num_class = 7, iclass = 0, ifreq[7], n = 70;
	Nag_ClassBoundary iclass_enum;
    double a[70] = {22.3, 21.6, 22.6, 22.4, 22.4, 22.4, 22.1, 21.9, 23.1, 23.4,
    				23.4, 22.6,	22.5, 22.5, 22.1, 22.6, 22.3, 22.4, 21.8, 22.3,
    				22.1, 23.6, 20.8, 22.2,	23.1, 21.1, 21.7, 21.4, 21.6, 22.5,
					21.2, 22.6, 22.2, 22.2, 21.4, 21.7, 23.2, 23.1, 22.3, 22.3,
					21.1, 21.4, 21.5, 21.8, 22.8, 21.4, 20.7, 21.6, 23.2, 23.6,
					22.7, 21.7, 23.0, 21.9, 22.6, 22.1, 22.2, 23.4, 21.5, 23.0,
    				22.8, 21.4, 23.2, 21.8, 21.2, 22.0, 22.4, 22.8, 23.2, 23.6};
     
    iclass_enum = Nag_ClassBoundaryComp;   

	sucess = nag_frequency_table(n, a, num_class, iclass_enum, c, ifreq, &xmin, &xmax );

		
   	printf("Number of cases is %d\n", n);
   	printf("Number of calsses, including extreme classes %d\n", num_class);
   	printf("routine -supplied class boundary\n\n\n");
   	
   	printf("the data are as following\n");
   	
   	for(i=0; i<70; i++)
	{
		printf("%10.1f", a[i]);
		if((i+1)%10 == 0)
		printf("\n");
	}
	
	printf("\nsucess is%d\n", sucess);	
	
	if(sucess == 0)
	{
		printf("\nsucessfully call of the  function nag_frequency_table\n");
		printf("the output is following:\n");
		printf("***     Frequency distribution   ***\n");
		printf("        class             frequency\n");
		printf("up to           %5.2f             %d\n", c[0],ifreq[0]);
		for (i = 2; i<(num_class - 1); i++)
			printf("%5.2f  to   %5.2f             %d\n",c[i-2], c[i-1], ifreq[i-1]);
		printf("%5.2f        and over             %d\n", c[num_class - 2],ifreq[num_class-1]);
		printf("Total frequency  = 70 \n" );
		printf("Minimun                   %10.1f\n", xmin);
		printf("Maximum                   %10.1f\n", xmax);

	}
	else
	{
		printf(" \n There are some problems.");
	}
	
}

The output is following:

***     Frequency distribution   ***
        class             frequency
up to       20.70   	       0
20.70  to   21.28       	   6
21.28  to   21.86             16
21.86  to   22.44             21
22.44  to   23.02             14
23.60  and over		           0
Total frequency  = 70 
Minimum                   20.7
Maximum                   23.6

Return:
	The function returns NAG error code or 0 if no error.
	
	NE_INT_ARG_LT(11):	On entry, num_class must not be less than 2: num_class = <value>.  On entry, n must not be less than 1: n  =  <value>.
	NE_BAD_PARAM(70): On entry, parameter class had an ellegal value.
	NE_NOT_STRICTLY_INCREASING(63):	The sequence cint is not strictly increasing: cint[<value>] = <value>, cint[<value>] = <value>.
	NE_INTERNAL_ERROR(74): An internal error has occurred in this function.  Check the function call and array sizes.  If the function call is correct, please consult NAG for assistance.

	success is 0
	sucessfully call of the  function nag_frequency_table
	
*/

int nag_frequency_table(
	int n, // the number of observations
	const double x[], // the sample of observations, x[i]. i = 0,1,2,...,n 
	int num_class,	// the number of classes desired in the frequency distribution
	Nag_ClassBoundary class_val,
	double cint[],
	int ifreq[],
	double *xmin,	// the smallest value in the sample
	double *xmax	// the largest value in the sample
);	// Frequency table from raw data

/**	g01alc
		calculates a five-point summary for a single sample.

Example:

void test_nag_5pt_summary_stats()
{
	double res[5];
	int i, sucess, n=12;
	double x[12] = {12.0, 9.0, 2.0, 5.0, 6.0, 8.0, 2.0, 7.0, 3.0, 1.0, 11.0, 10.0};
	
	printf("\n the number of data is 12 and as following\n");
	for( i=0; i<12; i++)
		printf("%5.1f  ", x[i]);

	sucess = nag_5pt_summary_stats(n, x, res);
	if(sucess == 0)
	{
		printf("\nThe function has been sucessfully called\n");
		printf("the results are the following\n");
		printf("Maximum			 %8.4f\n", res[4]);
		printf("Upper hinge 	 %8.4f\n", res[3]);
		printf("Median			 %8.4f\n", res[2]);
		printf("Lower hinge		 %8.4f\n", res[1]);
		printf("Minimum			 %8.4f\n", res[0]);		
	}
	else
		printf("The call is unsucessful.");
}
	 
	The output is following:

	Maximum			  12.0000
	Upper hinge 	   9.5000
	Median			   6.5000
	Lower hinge		   2.5000
	Minimum			   1.0000 
	
Return:
	The function returns NAG error code or 0 if no error.
	
	NE_INT_ARG_LT(11): On entry, n must not be less than 5: n = _value_.
	NE_ALLOC_FAIL(73): Memory allocation failed.
	NE_INTERNAL_ERROR(74): An internal error has occurred in this function. Check the function call and array sizes.
	If the function call is correct, please consult NAG for assistance.
	
	successfully call of the nag_5pt_summary_stats function.
*/

int nag_5pt_summary_stats(
	int n, // the number of observations
	double x[], // the sample of observations, x[i]. i = 0,1,2,...,n
	double res[]
);	// Five-point summary (median, hinges and extremes)

/**	g01bjc
		returns the lower tail, upper tail and point probabilities associated with a Binomial distribution.

Example:

void test_nag_binomial_dist()
{
	double plek, peqk, pgtk;
	int sucess, i;
	double p[4] = {0.5, 0.440, 0.750, 0.330};	
	int n[4] = {4, 19, 100, 2000};
	int k[4] = {2, 13, 67, 700};
	
	printf("    n        p    k       plek        pgtk          peqk\n");
	for(i=0; i<4; i++)
	{
		sucess = nag_binomial_dist(n[i], p[i], k[i], &plek,	&pgtk, &peqk);
		if(sucess == 0)
			printf("%4d     %4.3f  %3d    %6.5f     %6.5f       %6.5f \n",n[i], p[i], k[i], plek, pgtk, peqk);
		else	
			break;
	}
	if(sucess != 0)
		printf(" the function is not sucessfully called");	
}
	
	The output is following:
	
	    n        p    k       plek        pgtk          peqk
	   4     0.500    2    0.68750     0.31250       0.37500 
	  19     0.440   13    0.99138     0.00862       0.01939 
	 100     0.750   67    0.04460     0.95540       0.01700 
	2000     0.330  700    0.97251     0.02749       0.00312 

Return:
	The function returns NAG error code or 0 if no error.
		
	NE_2_INT_ARG_GT(19): On entry, k = _value_ while n = _value_. These parameters must satisfy k = n.
	NE_ARG_TOO_LARGE(410): On entry, n is too large to be represented exactly as a double precision number.
	NE_INT_ARG_LE(12):	On entry, p must not be less than or equal to 0.0: p = _value_.
	NE_REAL_ARG_GE(8): On entry, p must not be greater than or equal to 1.0: p = _value_.
	NE_VARIANCE_TOO_LARGE(411): On entry, the variance (= np(1 - p)) exceeds 106.
	NE_INTERNAL_ERROR(74): An internal error has occurred in this function. Check the function call and array sizes.
	If the function call is correct, please consult NAG for assistance.
	
	successfully call of the nag_binomial_dist	
*/

int nag_binomial_dist(
	int n,	// the parameter n of the binomial distribution
	double p,	// the parameter p of the binomial distribution
	int k,	// the integer k which defines the required probabilities
	double *plek,	// the lower tail probability
	double *pgtk,	// the upper tail probability
	double *peqk	// the point probability
);	// Binomial distribution function

/**	g01bkc
		returns the lower tail, upper tail and point probabilities
		associated with a Poisson distribution.
	
Example:  

void test_nag_poisson_dist()
{
	double plek, peqk, pgtk;
	int sucess, i;
	int k[4] = {3, 12, 25, 175};	
	double rlamda[4] = {0.75, 9.20, 34.00, 175.00};
    
    printf("  rlamda      k        plek        pgtk          peqk\n");
	for(i=0; i<4; i++)
	{
		sucess = nag_poisson_dist(rlamda[i], k[i], &plek, &pgtk, &peqk);
		if(sucess == 0)
			printf("%6.3f     %4d     %6.5f     %6.5f       %6.5f \n",rlamda[i], k[i], plek, pgtk, peqk);
		else	
			break;
	}
	if(sucess != 0)
		printf(" the function is not sucessfully called");		
}

	The output is following:
		
	  rlamda      k        plek        pgtk          peqk
	 0.750        3     0.99271     0.00729       0.03321 
	 9.200       12     0.86074     0.13926       0.07755 
	34.000       25     0.06736     0.93264       0.02140 
	175.000      175     0.52009     0.47991       0.03014 
	
Return:
	The function returns NAG error code or 0 if no error.
	
	NE_INT_ARG_LT(11): On entry, k must not be less than 0: k = _value_.
	NE_REAL_ARG_LE(6): On entry, rlamda must not be less than or equal to 0.0: rlamda = _value_.
	NE_REAL_ARG_GT(7): On entry, rlamda must not be greater than 106: rlamda = _value_.	
	NE_INTERNAL_ERROR(74): An internal error has occurred in this function. Check the function call and array sizes.
	If the function call is correct, please consult NAG for assistance.

	successfully call of the nag_poisson_dist function
*/

int nag_poisson_dist(
	double rlamda,	// the parameter lambda of the poisson distribution
	int k,	// the integer k which defines the required probabilities
	double *plek,	// the lower tail probability
	double *pgtk,	// the upper tail probability
	double *peqk	// the point probability
);	// Poisson distribution function

⌨️ 快捷键说明

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