home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 21 / macformat_21.iso / Shareware / Programación / VideoToolbox / (Utilities) / Quick3 / Quick3.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-26  |  2.0 KB  |  63 lines  |  [TEXT/CWIE]

  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. 5/27/95 dgp replaced #include <math.h> by #include "VideoToolbox.h", since I routinely
  9.             compile everything with the VideoToolbox precompiled header, which
  10.             normally included fp.h instead of math.h.
  11. */
  12. #pragma once    /* prevent multiple inclusions of this file */
  13. #include "VideoToolbox.h"
  14. #if !defined(_STDIO)
  15.     #include <stdio.h>
  16. #endif
  17. #if !defined(_STDLIB)
  18.     #include <stdlib.h>
  19. #endif
  20. #define MAX_CONTRASTS 200
  21. #define ILLEGAL_PARAMETERS -1.0    /* unique value indicating parameters out of bounds */
  22. #define MACINTOSH 1
  23. #ifndef exp10
  24.     #define exp10(x) exp(LOG10*(x))            /* faster than pow(10.0,x) */
  25. #endif
  26. #undef pow
  27. #define pow(x,y) exp(log(x)*(y))            /* faster by use of 68881 instructions */
  28. #if !defined(LOG10)
  29.     #define LOG10    2.30258509299404568402    /* computed in Mathematica */
  30. #endif
  31.  
  32. typedef struct {
  33.     double contrast;
  34.     long trials;
  35.     long correct;
  36. } contrastRecord;
  37.  
  38. typedef struct {
  39.     long contrasts;
  40.     contrastRecord c[MAX_CONTRASTS];    /* an array of records is easier to sort */
  41. } dataRecord;
  42.  
  43. typedef struct {
  44.     double logAlpha;
  45.     double beta;
  46.     double gamma;
  47.     double delta;
  48. } paramRecord;
  49.  
  50. #define PARAMS ((short)(sizeof(paramRecord)/sizeof(double)))
  51.  
  52. typedef double (*PsychometricFunctionPtr)(double contrast,paramRecord *paramPtr);
  53.  
  54. double Weibull(double contrast,paramRecord *paramPtr);
  55. double LogLikelihood(dataRecord *data,paramRecord *params,
  56.     PsychometricFunctionPtr PsychFun);
  57. double PsychometricFit(paramRecord *paramPtr
  58.     ,PsychometricFunctionPtr PsychFun
  59.     ,dataRecord *dataPtr,double *logLikelihoodPtr,int degreesOfFreedom
  60.     ,double *chiSquarePtr,int *chiSquareDFPtr);
  61. void MonotonicFit(dataRecord *data,double *logLikelihoodPtr,int *degreesOfFreedomPtr);
  62. void SortAndMergeContrasts(dataRecord *dataPtr);
  63.