1 /* Copyright 2008 Jason Kim Chong Polak
3 Please respect the following:
5 This file is part of bioCity. bioCity is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "FuncSelect.hh"
24 FuncSelect::FuncSelect( )
26 func_name
= "default";
29 FuncSelect::FuncSelect(
30 string _func_name
= "default",
31 double *_params
= NULL
,
36 func_name
= _func_name
;
37 params_len
= _params_len
;
38 params
= new double[params_len
];
39 rgen
= _r
; //we don't want to deep copy!!!
41 for (int i
= 0; i
< params_len
; i
++)
43 params
[i
] = _params
[i
];
47 FuncSelect::~FuncSelect( )
55 double FuncSelect::evaluate()
59 if ( func_name
== "default" )
62 cout
<<"#Warning! Default selected...."<<endl
;
63 } //Random Number Distributions
64 else if ( func_name
== "gsl_cdf_gaussian_P" )
66 double quantile
= params
[0];
67 double mean
= params
[1];
68 double var
= params
[2];
69 result
= gsl_cdf_gaussian_P( quantile
- mean
, var
);
71 else if (func_name
== "gsl_cdf_exponential_P" )
73 double quantile
= params
[0];
74 double mu
= params
[1]; // here f(x) = 1/mue^(-x/mu)
75 result
= gsl_cdf_exponential_P( quantile
, mu
);
77 else if ( func_name
== "gsl_cdf_gamma_P" )
79 double quantile
= params
[0];
82 result
= gsl_cdf_gamma_P( quantile
, a
, b
);
84 else if ( func_name
== "gsl_cdf_tdist_P" )
86 double quantile
= params
[0];
87 double nu
= params
[1];
88 result
= gsl_cdf_tdist_P( quantile
, nu
);
90 else if ( func_name
== "yousuck")
96 cout
<<"#Warning! Some function was specified that is not in the database."<<endl
;