Sha256: 41d948f6a87dcb27743f1e6cf3d44e56e4cce933e1d928f3471c5d28b1503611

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

module NumberCrusher
  def KdeBandwidthFinder(sample = nil, **options)
    function = KdeBandwidthFinder.new(**options)
    sample ? function.call(sample) : function
  end

  class KdeBandwidthFinder
    def initialize(function:, xs:, bandwidths:, finder:)
      @function = function
      @xs = xs
      @bandwidths = bandwidths
      @finder = finder
    end

    def call(sample)
      @bandwidths.bsearch do |width|
        k = KernelDensityEstimator(sample,
                                   function: @function,
                                   bandwidth: width,
                                   xs: @xs)
        @finder.call(k)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
number_crusher-0.1.2 lib/number_crusher/kde_bandwidth_finder.rb
number_crusher-0.1.1 lib/number_crusher/kde_bandwidth_finder.rb