aboutsummaryrefslogtreecommitdiffstats
path: root/distributions
diff options
context:
space:
mode:
Diffstat (limited to 'distributions')
-rw-r--r--distributions/uniformed.hpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/distributions/uniformed.hpp b/distributions/uniformed.hpp
new file mode 100644
index 0000000..ccafd01
--- /dev/null
+++ b/distributions/uniformed.hpp
@@ -0,0 +1,58 @@
+#ifndef UNIFORMED_MODEL_H_
+#define UNIFORMED_MODEL_H_
+#define OPT_HEADER
+#include <core/fitter.hpp>
+#include <cmath>
+#include <misc/optvec.hpp>
+
+namespace opt_utilities
+{
+ template <typename T>
+ class uniformed
+ :public model<optvec<T>,optvec<T>,optvec<T>,std::string>
+ {
+ private:
+ uniformed* do_clone()const
+ {
+ return new uniformed<T>(*this);
+ }
+
+ const char* do_get_type_name()const
+ {
+ return "1d normed gaussian";
+ }
+ public:
+ uniformed()
+ {
+ this->push_param_info(param_info<optvec<T> >("a",0.));
+ this->push_param_info(param_info<optvec<T> >("b",1.));
+ }
+
+
+ public:
+ optvec<T> do_eval(const optvec<T>& x,const optvec<T>& param)
+ {
+ T a=get_element(param,0);
+ T b=get_element(param,1);
+ optvec<T> y;
+ resize(y,get_size(x));
+ for(int i=0;i<get_size(x);++i)
+ {
+ T v=get_element(x,i);
+ set_element(y,i,(v-a)*(v-b)<0?1/abs(b-a):0);
+ }
+ return y;
+ }
+
+ private:
+ std::string do_get_information()const
+ {
+ return "";
+ }
+ };
+}
+
+
+
+#endif
+//EOF