Exemplo n.º 1
0
inline double dcdflib_f_quantile(double p, double df1, double df2)
{
   int what = 2;
   int status = 0;
   double x, bound, q(1 - p);
   cdff(&what, &p, &q, &x, &df1, &df2, &status, &bound);
   return x;
}
Exemplo n.º 2
0
inline double dcdflib_f_cdf(double x, double df1, double df2)
{
   int what = 1;
   int status = 0;
   double p, q, bound;
   cdff(&what, &p, &q, &x, &df1, &df2, &status, &bound);
   return p;
}
Exemplo n.º 3
0
void V_cdff(int *which, double *p, double *q, double *f, double *dfn,
	    double *dfd, int *status, double *bound, int *len)
{
    int i;
    for (i = 0; i < *len; i++) {
	cdff((int *)which, &p[i], &q[i], &f[i], &dfn[i],
	     &dfd[i], (int *)&status[i], &bound[i]);
    }
}
double tstat(double t,double df)
{
	int which,status;
	double p,q,f,dfn,dfd,bound;
	f=t*t;
	which=1;
	dfn=1;
	dfd=df;
	cdff(&which,&p,&q,&f,&dfn,&dfd,&status,&bound);
	return q;
}
Exemplo n.º 5
0
int main( void )
{
  int which,status;
  double p,q,f,dfn,dfd,bound;

  p=0.95;
  q=1.-p;
  dfn=6.0;
  dfd=5.0;
  bound=1.0e50;
  which=2;
  /** Compute  F to initialize the parameters **/
  cdff(&which,&p,&q,&f,&dfn,&dfd,&status,&bound);
  printparameters(p,q,f,dfn,dfd,bound,status);
  /*** Recompute dfn, dfd **/
  which=3;
  cdff(&which,&p,&q,&f,&dfn,&dfd,&status,&bound);
  printparameters(p,q,f,dfn,dfd,bound,status);
  return 0;
}
Exemplo n.º 6
0
static int cdf_pf (lua_State *L) {
  /* stack should contain f, dfn, dfd and opt. phonc */
  lua_Number f = luaL_checknumber(L, 1);
  lua_Number dfn = luaL_checknumber(L, 2);
  lua_Number dfd = luaL_checknumber(L, 3);
  lua_Number phonc = luaL_optnumber(L, 4, 0);
  lua_Number p, q, bound;
  int which = 1;
  int status;
  check_f(L, 1, f, dfn, dfd);
  if (phonc == 0) /* central? */
    cdff(&which, &p, &q, &f, &dfn, &dfd, &status, &bound);
  else /* non-central */
    cdffnc(&which, &p, &q, &f, &dfn, &dfd, &phonc, &status, &bound);
  check_status(status, bound);
  lua_pushnumber(L, p);
  return 1;
}
Exemplo n.º 7
0
static int cdf_qf (lua_State *L) {
  /* stack should contain p, dfn, dfd and opt. phonc */
  lua_Number p = luaL_checknumber(L, 1);
  lua_Number dfn = luaL_checknumber(L, 2);
  lua_Number dfd = luaL_checknumber(L, 3);
  lua_Number phonc = luaL_optnumber(L, 4, 0);
  lua_Number f;
  check_f(L, 2, p, dfn, dfd);
  if (p==0 || p==1) f = (p==0) ? 0 : HUGE_VAL;
  else {
    lua_Number q = 1-p;
    lua_Number bound;
    int which = 2;
    int status;
    if (phonc == 0) /* central? */
      cdff(&which, &p, &q, &f, &dfn, &dfd, &status, &bound);
    else /* non-central */
      cdffnc(&which, &p, &q, &f, &dfn, &dfd, &phonc, &status, &bound);
    check_status(status, bound);
  }
  lua_pushnumber(L, f);
  return 1;
}