Class kde_python (o2scl)

O2scl : Class List

template<class vec_t = std::vector<double>>
class kde_python : public o2scl::prob_dens_mdim<std::vector<double>>

Multidimensional interpolation interface for python.

Public Functions

inline kde_python()
inline kde_python(std::string module, o2scl::tensor<> &params, std::vector<double> array, std::string options = "", std::string class_name = "", int v = 0)

Specify the Python module and function.

inline virtual ~kde_python()

Free memory associated with the KDE.

inline void free()

Free the associated memory.

inline const o2scl::tensor &get_data()

Get the data.

inline int set_function(std::string module, o2scl::tensor<> &params, std::vector<double> array, std::string options = "", std::string class_name = "", int v = 0)

Specify the python and the parameters.

This function is called by the constructor and thus cannot be virtual.

inline void *set_function_internal(std::string module, o2scl::tensor<> &params, std::vector<double> array, int &ret, std::string options = "", std::string class_name = "", int v = 0)

Internal version of set_function()

inline virtual size_t dim() const

Return the dimensionality.

inline void *log_pdf_internal(const vec_t &x, double &dout) const

The normalized density.

inline virtual double log_pdf(const vec_t &x) const

The normalized density.

inline virtual double get_bandwidth() const

Get the bandwidth.

inline virtual double pdf(const vec_t &x) const

The normalized density.

inline void *operator2(vec_t &x) const

Sample the distribution.

This is a void * version of operator() which doesn’t cause problems with the import_array() macro.

inline virtual void operator()(vec_t &x) const

Sample the distribution.

Public Members

bool array_copy

If true, then make a copy of the array before calling log_pdf() (default true)

Todo:

This should be done by a template specialization instead of a bool flag

std::string set_func

The name of the set function (default “set_data_str”)

std::string sample_func

The name of the sample function (default “sample”)

std::string ld_func

The name of the log pdf function (default “log_pdf”)

Protected Attributes

PyObject *p_module

Python module containing function.

PyObject *p_class

The class.

PyObject *p_instance

An instance of the class.

PyObject *p_set_args

Function arguments.

PyObject *p_ld_args

Function arguments.

PyObject *p_set_func

Python function.

PyObject *p_sample_func

Python function.

PyObject *p_ld_func

Python function.

size_t n_params

Number of parameters.

size_t n_points

Number of points.

o2scl::tensor data

Data.

Private Functions

kde_python(const kde_python&)
kde_python &operator=(const kde_python&)