#include <assert.h>
#include <math.h>

double logisticDF(double x, double a, double b)
{
   assert(b > 0);
   return 1./(1+exp((a-x)/b));
}

double inv_logisticDF(double q, double a, double b)
{
   assert(b > 0 && q > 0 && q < 1.);
   return a-b*log(1./q-1);
}

#ifdef TEST

void main(void)
{
   double x, y, a, b;

   while (1) {
      printf("\n\n\rEnter a: ");
      scanf("%lg", &a);
      if (a <= 0)
	 break;
      printf("Enter b: ");
      scanf("%lg", &b);

      for(x=-8; x < 8; x += 0.32)
      {
         y=logisticDF(x, a, b);
         printf("x=%lg \t l=%lg  \t  i=%lg\n",
            x, y, inv_logisticDF(y, a, b));
      }
   }
}

#endif
