home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Libraries / VideoToolbox 94.11.17 / Utilities / Quick3 / Quick3.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-01  |  2.0 KB  |  64 lines  |  [TEXT/KAHL]

  1. /* Quick3.h
  2. HISTORY:
  3. 3/10/92 dgp    Cast PARAMS to be a short int.
  4.             If appropriate, use the 68881 log and exp instructions for speed.
  5.             For speed, defined exp10(), and use exp and log to compute pow.
  6.             These changes speed up the computation enormously, perhaps 50-fold,
  7.             yet when run on "sample.data" the resulting "sample.fit" is unchanged.
  8. */
  9. #pragma once    /* prevent multiple inclusions of this file */
  10. #if defined(powerc)
  11.     #include <fp.h>
  12. #else
  13.     #include <math.h>
  14. #endif
  15. #include <stdio.h>    /* needed for prototypes */
  16. #include <stdlib.h>
  17. #define MAX_CONTRASTS 200
  18. #define ILLEGAL_PARAMETERS -1.0    /* unique value indicating parameters out of bounds */
  19. #define MACINTOSH 1
  20. #include "mc68881.h"
  21. #if (THINK_C || THINK_CPLUS) && mc68881
  22.     #define exp _exp    /* use fast 68881 instruction instead of SANE */
  23.     #define log _log    /* use fast 68881 instruction instead of SANE */
  24. #endif
  25. #ifndef exp10
  26.     #define exp10(x) exp(LOG10*(x))            /* faster than pow(10.0,x) */
  27. #endif
  28. #define pow(x,y) exp(log(x)*(y))            /* faster by use of 68881 instructions */
  29. #if !defined(LOG10)
  30.     #define LOG10    2.30258509299404568402    /* computed in Mathematica */
  31. #endif
  32.  
  33. typedef struct {
  34.     double contrast;
  35.     long trials;
  36.     long correct;
  37. } contrastRecord;
  38.  
  39. typedef struct {
  40.     long contrasts;
  41.     contrastRecord c[MAX_CONTRASTS];    /* an array of records is easier to sort */
  42. } dataRecord;
  43.  
  44. typedef struct {
  45.     double logAlpha;
  46.     double beta;
  47.     double gamma;
  48.     double delta;
  49. } paramRecord;
  50.  
  51. #define PARAMS ((short)(sizeof(paramRecord)/sizeof(double)))
  52.  
  53. typedef double (*PsychometricFunctionPtr)(double contrast,paramRecord *paramPtr);
  54.  
  55. double Weibull(double contrast,paramRecord *paramPtr);
  56. double LogLikelihood(dataRecord *data,paramRecord *params,
  57.     PsychometricFunctionPtr PsychFun);
  58. double PsychometricFit(paramRecord *paramPtr
  59.     ,PsychometricFunctionPtr PsychFun
  60.     ,dataRecord *dataPtr,double *logLikelihoodPtr,int degreesOfFreedom
  61.     ,double *chiSquarePtr,int *chiSquareDFPtr);
  62. void MonotonicFit(dataRecord *data,double *logLikelihoodPtr,int *degreesOfFreedomPtr);
  63. void SortAndMergeContrasts(dataRecord *dataPtr);
  64.