Файл logisticDF.h
#ifndef __LOGISTIC_H__ /* To prevent redefinition */
#define ENTRY extern #define LOCAL static
ENTRY double logisticDF(double x, double a, double b); ENTRY double inv_logisticDF(double q, double a, double b);
#define __LOGISTIC_H__ /* Prevents redefinition */ #endif /* Ends #ifndef__LOGISTIC_H__ */
Файл logisticDF.cpp
#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
#include <iostream.h>
void main(void) { double a, b;
while (1) { cout << "\n\n\rEnter a: "; cin >> a; if (a <= 0) break; cout << "Enter b: "; cin >> b;
for(double x=-8; x < 8; x += 0.32) { double y=logisticDF(x, a, b); double z=inv_logisticDF(y, a, b); cout << "x=" << x << "\tl=" << y << "\ti=" << z << endl; } } }
#endif
1 2
8 8 8
| |