Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

lrtest.cpp File Reference

The data values are from Table 6.1 in "Statistics Manual" by Crow, Davis, Maxfield, Dover Press. More...

#include <assert.h>
#include <stdio.h>
#include <lregress.h>

Go to the source code of this file.

Functions

void init_data (vector< lregress::point > &data)
 Initialize the data vector container with data from the X and Y vectors. More...

 main ()


Detailed Description

The data values are from Table 6.1 in "Statistics Manual" by Crow, Davis, Maxfield, Dover Press.

According to "Statistics Manual"

         b = 7.35476

         a = -337.983

for the equation y' = a + bx

Definition in file lrtest.cpp.


Function Documentation

void init_data ( vector< lregress::point > & data )
 

Initialize the data vector container with data from the X and Y vectors.

Definition at line 33 of file lrtest.cpp.

Referenced by main().

00034 {
00035   static double X[] = { 55.77,
00036                         55.05,
00037                         54.27,
00038                         50.63,
00039                         49.86,
00040 
00041                         53.04,
00042                         51.33,
00043                         56.70,
00044                         55.07,
00045                         55.76,
00046                
00047                         54.40,
00048                         55.39,
00049                         57.49,
00050                         57.56,
00051                         58.76,
00052                
00053                         59.32,
00054                         57.21,
00055                         68.55,
00056                         65.04,
00057                         66.98,
00058 
00059                         63.69,
00060                         58.34 };
00061 
00062   static double Y[] = { 83.9,
00063                         66.4,
00064                         73.1,
00065                         66.7,
00066                         30.1,
00067                
00068                         36.2,
00069                         22.8,
00070                         66.5,
00071                         37.0,
00072                         58.0,
00073 
00074                         71.9,
00075                         83.1,
00076                         66.2,
00077                         72.3,
00078                         65.8,
00079 
00080                         123.5,
00081                         116.8,
00082                         160.1,
00083                         158.2,
00084                         152.2,
00085 
00086                         134.8,
00087                         87.3 };
00088 
00089   const size_t N = sizeof( X ) / sizeof( double );
00090   assert( N == (sizeof( Y ) / sizeof(double)) );
00091 
00092   size_t i;
00093   for (i = 0; i < N; i++) {
00094     lregress::point p( X[i], Y[i] );
00095     data.push_back( lregress::point( p ) );
00096   }
00097 } // init_data

main ( )
 

Definition at line 100 of file lrtest.cpp.

00101 {
00102   lregress lr;
00103   lregress::lineInfo info;
00104 
00105   vector<lregress::point> data;
00106   init_data( data );
00107   const size_t N = data.size();
00108 
00109   size_t i;
00110   // print out the points
00111   for (i = 0; i < N; i++) {
00112     // printf("%7.4f  %7.4f\n", data[i].x(), data[i].y() );
00113   }
00114 
00115   lr.lr( data, info );
00116 
00117   printf("b (slope) = %7.4f, a (intercept) = %7.4f\n", 
00118          info.slope(), 
00119          info.intercept()
00120          );
00121   printf(" slopeErr = %7.4f, stddev = %7.4f, corr = %7.4f\n",
00122          info.slopeErr(), info.stddev(), info.corr() );
00123 
00124   double yPrime;
00125   for (i = 0; i < N; i++) {
00126     yPrime = info.intercept() + (info.slope() * data[i].x());
00127     // printf("%7.4f  %7.4f\n", data[i].x(), yPrime );
00128   }
00129 
00130 } // main


Generated at Wed May 21 21:19:27 2003 for Basic Statistics Functions by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001