|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T s
Length: 1682 (0x692)
Types: TextFile
Names: »stats.c«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen
└─⟦this⟧ »cph85dist/stat/src/stats.c«
/* just some compuations localized for reference */
#include <stdio.h>
#include <math.h>
readdata ()
{
int n; /* the number of points read in */
double s1; /* sum of scores */
double s2; /* sum of squared scores */
double s3; /* sum of cubed scores */
double s4; /* sum of forth powered scores */
double x; /* the value read in */
double x2; /* the value squared */
char word[BUFSIZ]; /* data as strings read in here */
n = 0;
s1 = s2 = s3 = s4 = 0.0;
while (getword (word, stdin))
{
if (number (word))
{
x = atof (word);
x2 = x * x;
s1 += x;
s2 += x2;
s3 += x * x2;
s4 += x2 * x2;
n++;
}
}
printstats (n, s1, s2, s3, s4);
}
#define print(val,format) printf ("%-10s = %format\n", "val", val)
printstats (n, s1, s2, s3, s4)
int n; /* the number of points read in */
double s1; /* sum of scores */
double s2; /* sum of squared scores */
double s3; /* sum of cubed scores */
double s4; /* sum of forth powered scores */
{
double sqrt ();
double mean = 0.0;
double var = 0.0;
double sd = 0.0;
double skew;
double kurtosis;
double m2;
print (n,8d);
if (n > 0)
{
mean = s1/n;
m2 = mean * mean;
print (mean,8.3f);
if (n > 1)
{
var = (s2 - mean*s1)/(n-1);
sd = sqrt (var);
print (sd,8.3f);
skew = (s3 - 3.0*mean*s2 + 3.0*m2*s1 - m2*s1)/(n*var*sd);
print (skew,8.3f);
kurtosis = (s4-4.*mean*s3+6.*m2*s2-4.*m2*mean*s1+n*m2*m2)/(n*var*var);
print (kurtosis,8.3f);
}
else printf ("printstats: No variability\n");
}
else printf ("printstats: No data\n");
}
main ()
{
readdata ();
}