view xthresh.c @ 333:cc3f9d1ca2cd

Ugly hack upon ugly hack: * extend adb__query() to take a bunch of other arguments that allow useful functionality through to the SOAP server; * alter the RadiusQuery reporter so that the count for tracks is returned through SOAP, punning one of the result fields for the purpose; * alter argv construction to be more dynamic, to reflect that the very presence of some arguments changes audioDB behaviour. Now test 0020 passes, only some 12 months after it was originally written, yay. Alter test 0050 also, so that the results are actually vaguely what would be expected from a radius search; they are not completely checked for correctness, but are (apart from the last two) the same as test 0040. I believe that the modifications are backward compatible; lightly testing with an old audioDB binary suggests that old-format SOAP queries continue to work. Currently too baby-encumbered to think of how to test this fully.
author mas01cr
date Mon, 01 Sep 2008 15:35:05 +0000
parents 3be15407e814
children
line wrap: on
line source
#include <gsl/gsl_sf.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(int argc, char *argv[]) {
  if(argc != 4) {
    fprintf(stderr, "Wrong number of arguments: %d\n", argc);
    exit(1);
  }

  long int meanN = strtol(argv[1], NULL, 10);

  double d = strtod(argv[2], NULL);
  double sigma2 = strtod(argv[3], NULL);

  double logw = (2 / d) * gsl_sf_log(-gsl_sf_log(0.99));
  double logxthresh = gsl_sf_log(sigma2) + logw
    - (2 / d) * gsl_sf_log(meanN)
    - gsl_sf_log(d/2)
    - (2 / d) * gsl_sf_log(2 / d)
    + (2 / d) * gsl_sf_lngamma(d / 2);

  printf("w: %f\n", exp(logw));
  printf("x_thresh: %f\n", exp(logxthresh));
  exit(0);
}