Skip to content
Snippets Groups Projects
Commit 114ee4a1 authored by David Flitney's avatar David Flitney
Browse files

*** empty log message ***

parent 5d508ad5
No related branches found
No related tags found
No related merge requests found
// $Id $ // $Id$
#include <cstdlib>
#include <cmath>
#include <iostream> #include <iostream>
#include <cstdlib>
#include <cmath> #include <cmath>
#include "infer.h"
extern "C" { extern "C" {
#include "libprob.h" #include "libprob.h"
}; };
#define POSIX_SOURCE 1 #define POSIX_SOURCE 1
#define USAGE "usage: infer <W> <u> <D> <S> <k1> [<k2> <k3>...<kN>]"
#if !defined(M_PI) #if !defined(M_PI)
#define M_PI (4 * atan(1.0)) #define M_PI (4 * atan(1.0))
#endif #endif
int main(unsigned int argc, char **argv) template <class T> T sqr(const T& value) { return value * value; }
{
if ( argc < 6 ) Infer::Infer(float dLh, float t, unsigned int V) {
{ Em_ = V * pow(2*M_PI,-2) * dLh * (sqr(t) - 1) * exp(-sqr(t)/2.0);
cerr << USAGE << endl; B_ = pow((gamma(2.5)*Em_)/(V*(0.5 + 0.5*erf(-t/sqrt(2)))),(2.0/3.0));
return EXIT_FAILURE;
} cout << "E{m} " << Em_ << endl;
cout << "Beta = " << B_ << endl;
argc--; }
float W = atof(argv[1]); argc--;
float u = atof(argv[2]); argc--;
int D = atoi(argv[3]); argc--;
int S = atoi(argv[4]); argc--;
float Em = S * pow(2*M_PI,-0.5*(D+1));
cout << "S * pow(2*M_PI,-0.5*(D+1)) = " << Em << endl;
Em = pow(W,-D);
cout << "pow(W,-D) = " << Em << endl;
Em = pow(u,D-1);
cout << "pow(u,D-1) = " << Em << endl;
Em = exp(-0.5*(u*u));
cout << "exp(-0.5*(u*u)) = " << Em << endl;
Em = S * pow(2*M_PI,-0.5*(D+1))*pow(W,-D)*pow(u,D-1)*exp(-0.5*(u*u));
cout << "Em = " << Em << endl;
cout << gamma(0.5*D+1)*Em << endl; float Infer::operator() (unsigned int k) {
cout << S*(0.5 + 0.5*erf(-u)) << endl; return 1 - exp(-Em_ * exp(-B_ * pow( k , 2.0 / 3.0)));
cout << (gamma(0.5*D+1)*Em)/(S*erf(-u)) << endl;
float B = pow((gamma(0.5*D+1)*Em)/(S*(0.5 + 0.5*erf(-u/sqrt(2)))),(2.0/(float)D));
cout << "Beta = " << B << endl;
for ( unsigned int n = 0; n < argc; n++ ) {
unsigned int k = atoi(argv[5 + n]);
cout << 1 - exp(-Em * exp(-B * pow( k * k, 2.0 / (float)D))) << endl;
}
return EXIT_SUCCESS;
} }
#if !defined(Infer_h) #if !defined(Infer_h)
#define Infer_h #define Infer_h
// $Id $ // $Id$
class Infer { class Infer {
public: public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment