Example #1
0
void sknuth_Permutation (unif01_Gen * gen, sres_Chi2 * res,
   long N, long n, int r, int t)
{
   double ValDelta[] = { 1.0 };
   smultin_Param *par;

   if (swrite_Basic)
      printf ("***********************************************************\n"
              "Test sknuth_Permutation calling smultin_Multinomial\n\n");

   par = smultin_CreateParam (1, ValDelta, smultin_GenerCellPermut, 3);
   if (NULL == res) {
      smultin_Multinomial (gen, par, NULL, N, n, r, 1, t, FALSE);
   } else {
      smultin_Res *resm;
      resm = smultin_CreateRes (par);
      smultin_Multinomial (gen, par, resm, N, n, r, 1, t, FALSE);
      sres_InitChi2 (res, N, -1, "sknuth_Permutation");
      statcoll_SetDesc (res->sVal1, "Serial sVal1");
      res->sVal1->NObs = resm->Collector[0]->NObs;
      tables_CopyTabD (resm->Collector[0]->V, res->sVal1->V, 1, N);
      tables_CopyTabD (resm->sVal2[0], res->sVal2, 0, gofw_NTestTypes - 1);
      tables_CopyTabD (resm->pVal2[0], res->pVal2, 0, gofw_NTestTypes - 1);
      smultin_DeleteRes (resm);
   }
   smultin_DeleteParam (par);
}
Example #2
0
void svaria_CollisionArgMax (unif01_Gen * gen, sres_Chi2 * res,
   long N, long n, int r, long k, long m)
{
   if (m > 1) {
      svaria_CollisionArgMax_00 (gen, res, N, n, r, k, m);

   } else if (m == 1) {
      double ValDelta[] = { -1.0 };
      smultin_Param *par;

      if (swrite_Basic) {
         printf (
          "***********************************************************\n"
          "Test svaria_CollisionArgMax calling smultin_Multinomial\n\n");
      }
      par = smultin_CreateParam (1, ValDelta, smultin_GenerCellMax, -3);
      if (NULL == res) {
         smultin_Multinomial (gen, par, NULL, N, n, r, 0, k, TRUE);
      } else {
         smultin_Res *resm;
         resm = smultin_CreateRes (par);
         smultin_Multinomial (gen, par, resm, N, n, r, 0, k, TRUE);
         sres_InitChi2 (res, N, -1, "svaria_CollisionArgMax");
         statcoll_SetDesc (res->sVal1, "CollisionArgMax sVal1");
         res->sVal1->NObs = resm->Collector[0]->NObs;
         tables_CopyTabD (resm->Collector[0]->V, res->sVal1->V, 1, N);
         tables_CopyTabD (resm->sVal2[0], res->sVal2, 0, gofw_NTestTypes - 1);
         tables_CopyTabD (resm->pVal2[0], res->pVal2, 0, gofw_NTestTypes - 1);
         smultin_DeleteRes (resm);
      }
      smultin_DeleteParam (par);
   } else {
     util_Warning (m <= 0, "svaria_CollisionArgMax:   m <= 0");
   }
}
Example #3
0
void sentrop_EntropyDisc (unif01_Gen * gen, sentrop_Res * res,
   long N, long n, int r, int s, int L)
/*
 * Use smultin_Multinomial to replace sentrop_EntropyDisc
 */
{
   int i;
   int t;
   long d;
   double x;
   smultin_Param *par;
   double ValDelta[] = { 0.0 };

   if (s > L) {
      EntropyDisc00 (gen, res, N, n, r, s, L);
      return;                     /* <--- Case "s > L" end up here.  */
   }

   if (swrite_Basic)
      WriteDataEnt (N, n, r, s, L);
   util_Assert (L % s == 0, "sentrop_EntropyDisc:   L % s != 0");

   d = num_TwoExp[s];
   t = L / s;

   x = d;
   for (i = 2; i <= t; i++)
      x *= d;

   par = smultin_CreateParam (1, ValDelta, smultin_GenerCellSerial, 3);
   if (NULL == res) {
      if (n / x <= 8.0)
         smultin_Multinomial (gen, par, NULL, N, n, r, d, t, TRUE);
      else
         smultin_Multinomial (gen, par, NULL, N, n, r, d, t, FALSE);
   } else {
      smultin_Res *resm;
      resm = smultin_CreateRes (par);
      if (n / x <= 8.0)
         smultin_Multinomial (gen, par, resm, N, n, r, d, t, TRUE);
      else
         smultin_Multinomial (gen, par, resm, N, n, r, d, t, FALSE);
      InitRes (res, N, 0, "sentrop_EntropyDisc");
      statcoll_SetDesc (res->Bas->sVal1, "EntropyDisc sVal1");
      res->Bas->sVal1->NObs = resm->Collector[0]->NObs;
      tables_CopyTabD (resm->Collector[0]->V, res->Bas->sVal1->V, 1, N);
      tables_CopyTabD (resm->sVal2[0], res->Bas->sVal2, 0, gofw_NTestTypes - 1);
      tables_CopyTabD (resm->pVal2[0], res->Bas->pVal2, 0, gofw_NTestTypes - 1);
      smultin_DeleteRes (resm);
   }
   smultin_DeleteParam (par);
}
Example #4
0
void sknuth_CollisionPermut (unif01_Gen * gen, sknuth_Res2 * res,
   long N, long n, int r, int t)
{
   double ValDelta[] = { -1.0 };
   smultin_Param *par;

   if (swrite_Basic)
      printf ("***********************************************************\n"
         "Test sknuth_CollisionPermut calling smultin_Multinomial\n\n");

   par = smultin_CreateParam (1, ValDelta, smultin_GenerCellPermut, -3);
   if (NULL == res) {
      smultin_Multinomial (gen, par, NULL, N, n, r, 0, t, TRUE);
   } else {
      smultin_Res *resm;
      resm = smultin_CreateRes (par);
      smultin_Multinomial (gen, par, resm, N, n, r, 0, t, TRUE);
      InitRes2 (res, N, resm->Mu[0], "sknuth_CollisionPermut");
      statcoll_SetDesc (res->Bas->sVal1, "CollisionPermut sVal1");
      statcoll_SetDesc (res->Pois->sVal1, "CollisionPermut sVal1");
      res->Pois->pLeft = resm->pCollLeft;
      res->Pois->pRight = resm->pCollRight;
      res->Pois->sVal1->NObs = resm->Collector[0]->NObs;
      res->Bas->sVal1->NObs = resm->Collector[0]->NObs;
      tables_CopyTabD (resm->Collector[0]->V, res->Bas->sVal1->V, 1, N);
      tables_CopyTabD (resm->Collector[0]->V, res->Pois->sVal1->V, 1, N);
      res->Pois->pVal2 = resm->pColl;
      res->Pois->sVal2 = resm->NbCollisions;
      tables_CopyTabD (resm->sVal2[0], res->Bas->sVal2, 0,
         gofw_NTestTypes - 1);
      tables_CopyTabD (resm->pVal2[0], res->Bas->pVal2, 0,
         gofw_NTestTypes - 1);
      smultin_DeleteRes (resm);
   }
   smultin_DeleteParam (par);
}