IMSL_NORM1SAMP

Syntax | Return Value | Arguments | Keywords | Discussion | Examples | Version History

The IMSL_NORM1SAMP function computes statistics for mean and variance inferences using a sample from a normal population.

Note
This routine requires an IDL Advanced Math and Stats license. For more information, contact your ITT Visual Information Solutions sales or technical support representative.

Syntax

Result = IMSL_NORM1SAMP(x [, CHI_SQ_NULL_HYP=value] [, CI_MEAN=variable] [, CI_VAR=variable] [, CHI_SQ_TEST=variable] [, CONF_MEAN=value] [, CONF_VAR=value] [, /DOUBLE] [, STDEV=variable] [, T_NULL_HYP=value] [, T_TEST=variable])

Return Value

The mean of the sample.

Arguments

x

One-dimensional array containing the observed values.

Keywords

CHI_SQ_NULL_HYP

Null hypothesis value for the chi-squared test for the variance. Default: CHI_SQ_NULL_HYP = 1.0

CI_MEAN

Named variable into which the two-element array containing the lower confidence limit for the mean, and the upper confidence limit for the mean is stored.

CI_VAR

Named variable into which the two-element array containing lower and upper confidence limits for the variance is stored.

CHI_SQ_TEST

Named variable into which the three-element array containing statistics associated with the chi-squared test is stored. The first element contains the degrees of freedom associated with the chi-squared test for variances, the second element contains the test statistic, and the third element contains the probability of a larger chi-squared value. The chi-squared test is a test of the hypothesis σ2 = σ20, where σ20 is the null hypothesis value as described in CHI_SQ_NULL_HYP.

CONF_MEAN

Confidence level (in percent) for two-sided interval estimate of the mean. The keyword CONF_MEAN must be between 0.0 and 100.0 and is often 90.0, 95.0, or 99.0. For a one-sided confidence interval with confidence level c (at least 50 percent), set CONF_MEAN = 100.0 – 2.0 x (100.0 – c). Default: 95-percent confidence interval is computed.

CONF_VAR

Confidence level (in percent) for two-sided interval estimate of the variances. Keyword CONF_VAR must be between 0.0 and 100.0 and is often 90.0, 95.0, or 99.0. For a one-sided confidence interval with confidence level c (at least 50 percent), set CONF_VAR = 100.0 – 2.0 x (100.0 – c). Default: 95-percent confidence interval is computed.

DOUBLE

If present and nonzero, double precision is used.

STDEV

Variable into which the standard deviation of the sample is stored.

T_NULL_HYP

Null hypothesis value for t test for the mean. Default: T_NULL_HYP = 0.0

T_TEST

Named variable into which the three-element array containing statistics associated with the t test is stored. The first element contains the degrees of freedom associated with the t test for the mean, the second element contains the test statistic, and the third element contains the probability of a larger t in absolute value. The t test is a test of the hypothesis μ = μ0, where μ0 is the null hypothesis value as described in T_NULL_HYP.

Discussion

Statistics for mean and variance inferences using a sample from a normal population are computed, including confidence intervals and tests for both mean and variance. The definitions of mean and variance are given below. The summation in each case is over the set of valid observations, based on the presence of missing values in the data.

Mean, return value

IMSL_NORM1SAMP-10.jpg

Standard deviation

IMSL_NORM1SAMP-11.jpg

The t statistic for the two-sided test concerning the population mean is given by:

IMSL_NORM1SAMP-12.jpg

where s and IMSL_NORM1SAMP-13.jpg

are given above. This quantity has a T distribution with n – 1 degrees of freedom.

The chi-squared statistic for the two-sided test concerning the population variance is given by:

IMSL_NORM1SAMP-14.jpg

where s is given above. This quantity has a χ2 distribution with n – 1 degrees of freedom.

Examples

Example 1

This example uses data from Devore (1982, p. 335), which is based on data published in the Journal of Materials. There are 15 observations; the mean is the only output.

x = [26.7, 25.8, 24.0, 24.9, 26.4, $ 
25.9, 24.4, 21.7, 24.1, 25.9, $ 
27.3, 26.9, 27.3, 24.8, 23.6] 
PRINT, 'Sample Mean = ', IMSL_NORM1SAMP(x) 
Sample Mean = 25.3133 

Example 2

This example uses the same data as the initial example. The hypothesis H0: μ = 20.0 is tested. The extremely large t value and the correspondingly small p-value provide strong evidence to reject the null hypothesis. First, a procedure to print the results is defined.

.RUN 
PRO print_results, mean, stdev, $ 
   ci_mean, t_test 
   PM, mean, Title = 'Sample Mean:' 
   PM, stdev, Title = 'Sample Standard Deviation:' 
   PM, '(', ci_mean(0), ci_mean(1), ')', $ 
      Title = '95% CI for the mean:' 
   PM, ' ' 
   PM, ' df = ', t_test(0), Title = 't-test statistics:' 
   PM, '   t       = ', t_test(1) 
   PM, '   p-value = ', t_test(2) 
END 
 
x = [26.7, 25.8, 24.0, 24.9, 26.4, 25.9, 24.4,$ 
   21.7, 24.1, 25.9, 27.3, 26.9, 27.3, 24.8, 23.6] 
mean = IMSL_NORM1SAMP(x, Stdev = stdev, Ci_Mean    = ci_mean, $ 
   T_Null_Hyp = 40.0, T_Test     = t_test) 
print_results, mean, stdev, ci_mean, t_test 
 
Sample Mean: 
     25.3133 
Sample Standard Deviation: 
    1.57882 
95% CI for the mean: 
   (      24.4390      26.1877)  
 
t-test statistics: 
    df      =       14.0000 
    t       =      -36.0277 
    p-value =        0.00000 

Version History

6.4

Introduced