类 BandwidthWeight

继承关系

基类

类文档

class BandwidthWeight : public gwm::Weight

基于带宽计算权重的类。 用户可以指定带宽的大小、类型和核函数类型。

带宽的类型有两种:可变和固定。 如果使用可变带宽,带宽大小 \(b\) 必须是整数,代表到最近的第 \(b\) 个点的距离。 如果使用固定带宽,带宽大小是距离值。

目前有五种核函数类型:Gaussian, Exponential, Bisquare, Tricube 和 Boxcar。 每种类型的对应一种函数。 用户只需要指定核函数类型以使实例调用对应的核函数。

公有类型

enum KernelFunctionType

核函数类型。

Values:

enumerator Gaussian

Gaussian 核函数 BandwidthWeight::GaussianKernelFunction()

enumerator Exponential

Exponential 核函数 BandwidthWeight::ExponentialKernelFunction()

enumerator Bisquare

Bisquare 核函数 BandwidthWeight::BisquareKernelFunction()

enumerator Tricube

Tricube 核函数 BandwidthWeight::TricubeKernelFunction()

enumerator Boxcar

Boxcar 核函数 BandwidthWeight::BoxcarKernelFunction()

typedef arma::vec (*KernelFunction)(arma::vec, double)

核函数

公有方法

inline BandwidthWeight()

构造一个新的 BandwidthWeight 对象。

inline BandwidthWeight(double size, bool adaptive, KernelFunctionType kernel)

构造一个新的 BandwidthWeight 对象。

参数:
  • size -- 带宽大小

  • adaptive -- 是否是可变带宽

  • kernel -- 核函数类型

inline BandwidthWeight(const BandwidthWeight &bandwidthWeight)

复制构造一个 BandwidthWeight 对象。

参数:

bandwidthWeight -- 要复制的对象引用

inline BandwidthWeight(const BandwidthWeight *bandwidthWeight)

从指针复制构造一个 BandwidthWeight 对象。

参数:

bandwidthWeight -- 要复制的对象指针

inline virtual std::unique_ptr<Weight> clone() const override

克隆该对象。

返回:

新创建的指针

virtual arma::vec weight(arma::vec dist) const override

从距离计算权重。

参数:

dist -- 距离向量

返回:

权重向量

inline double bandwidth() const

获取带宽大小。

返回:

带宽大小

inline void setBandwidth(double bandwidth)

设置带宽大小。

参数:

bandwidth -- 带宽大小

inline bool adaptive() const

获取是否使可变带宽。

返回:

true 是

返回:

false 否

inline void setAdaptive(bool adaptive)

设置是否使可变带宽。

参数:

bandwidth -- 是否使可变带宽

inline KernelFunctionType kernel() const

获取核函数类型。

返回:

KernelFunctionType 核函数类型

inline void setKernel(const KernelFunctionType &kernel)

设置核函数类型。

参数:

bandwidth -- 核函数类型

公有静态方法

static inline arma::vec GaussianKernelFunction(arma::vec dist, double bw)

Gaussian 核函数。

参数:
  • dist -- 距离向量

  • bw -- 带宽大小(和距离向量的单位相同)

返回:

权重值

static inline arma::vec ExponentialKernelFunction(arma::vec dist, double bw)

Exponential 核函数。

参数:
  • dist -- 距离向量

  • bw -- 带宽大小(和距离向量的单位相同)

返回:

权重值

static inline arma::vec BisquareKernelFunction(arma::vec dist, double bw)

Bisquare 核函数。

参数:
  • dist -- 距离向量

  • bw -- 带宽大小(和距离向量的单位相同)

返回:

权重值

static inline arma::vec TricubeKernelFunction(arma::vec dist, double bw)

Tricube 核函数。

参数:
  • dist -- 距离向量

  • bw -- 带宽大小(和距离向量的单位相同)

返回:

权重值

static inline arma::vec BoxcarKernelFunction(arma::vec dist, double bw)

Boxcar 核函数。

参数:
  • dist -- 距离向量

  • bw -- 带宽大小(和距离向量的单位相同)

返回:

权重值

公有静态属性

static std::unordered_map<KernelFunctionType, std::string> KernelFunctionTypeNameMapper
static std::unordered_map<bool, std::string> BandwidthTypeNameMapper
static KernelFunction Kernel[]