statistics.c

来自「最新的版本ACE-5.6.8,刚从外文网上搬下,与大家分享.」· C语言 代码 · 共 50 行

C
50
字号
/* $Id: statistics.c 81994 2008-06-16 21:23:17Z sowayaa $ */
/**************************************************************************
 *
 *  Copyright (C) 1995 Silicon Graphics, Inc.
 *
 *  These coded instructions, statements, and computer programs were
 *  developed by SGI for public use.  If any changes are made to this code
 *  please try to get the changes back to the author.  Feel free to make
 *  modifications and changes to the code and release it.
 *
 **************************************************************************/

/* FUZZ: disable check_for_math_include */
#include <math.h>
#include <stdlib.h>
#include "sysdep.h"
#include "bench.h"


double
mean(const double sum, const int n)
{
  if (n)
    {
      return(sum / n);
    }
  else
    {
      return(0);
    }
}


double
variance(const double sum, const double sumofsquares, const int n)
{
    double meanofsum;

    meanofsum = mean(sum, n);

    return (mean(sumofsquares,n) - (meanofsum * meanofsum));
}


double
stddev(const double sum, const double sumofsquares, const int n)
{
    return(sqrt(fabs(variance(sum, sumofsquares, n))));
}

⌨️ 快捷键说明

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