Alien-libhisto

 view release on metacpan or  search on metacpan

bundled/include/histo/histo.h  view on Meta::CPAN

histo_status_t histo_migrate_binary(const void *in_buf, size_t in_size, void **out_buf, size_t *out_size);

/* ========================================================================= */
/* Automated Optimal Bin Width Heuristics                                    */
/* ========================================================================= */

/**
 * @brief Binning estimation heuristic rules.
 */
typedef enum histo_bin_rule {
    HISTO_BIN_RULE_AUTO    = 0,  /**< Automatic selection: Freedman-Diaconis with fallback to Scott [Default] */
    HISTO_BIN_RULE_FD      = 1,  /**< Freedman-Diaconis: h = 2 * IQR * n^(-1/3) */
    HISTO_BIN_RULE_SCOTT   = 2,  /**< Scott's normal reference: h = 3.49 * std * n^(-1/3) */
    HISTO_BIN_RULE_STURGES = 3,  /**< Sturges' rule: k = ceil(log2(n) + 1) */
    HISTO_BIN_RULE_DOANE   = 4,  /**< Doane's rule: Sturges adjusted for skewness */
    HISTO_BIN_RULE_KNUTH   = 5   /**< Knuth's Bayesian optimal binning rule */
} histo_bin_rule_t;

/**
 * @brief Estimates optimal uniform bin parameters using the Freedman-Diaconis rule.
 *

bundled/include/histo/kde.h  view on Meta::CPAN

 */

#ifndef LIBHISTO_KDE_H
#define LIBHISTO_KDE_H

/**
 * @file kde.h
 * @brief Kernel Density Estimation (KDE) engine for libhisto.
 *
 * Provides 1-dimensional non-parametric continuous density estimation over raw samples
 * or discrete histogram bins with multiple kernel types, automatic bandwidth selection,
 * cumulative distribution evaluation, and random sampling.
 */

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>

#include "types.h"
#include "histo.h"

bundled/include/histo/kde.h  view on Meta::CPAN

typedef enum histo_kde_kernel {
    HISTO_KDE_KERNEL_GAUSSIAN     = 0,  /**< Gaussian kernel: K(u) = (1/sqrt(2pi)) * exp(-u^2 / 2) [Default] */
    HISTO_KDE_KERNEL_EPANECHNIKOV = 1,  /**< Epanechnikov kernel: K(u) = 3/4 * (1 - u^2) for |u| <= 1 */
    HISTO_KDE_KERNEL_UNIFORM      = 2,  /**< Uniform / Boxcar kernel: K(u) = 1/2 for |u| <= 1 */
    HISTO_KDE_KERNEL_TRIANGULAR   = 3,  /**< Triangular kernel: K(u) = 1 - |u| for |u| <= 1 */
    HISTO_KDE_KERNEL_BIWEIGHT     = 4,  /**< Biweight / Quartic kernel: K(u) = 15/16 * (1 - u^2)^2 for |u| <= 1 */
    HISTO_KDE_KERNEL_COSINE       = 5   /**< Cosine kernel: K(u) = (pi/4) * cos(pi/2 * u) for |u| <= 1 */
} histo_kde_kernel_t;

/**
 * @brief Automated bandwidth selection rules.
 */
typedef enum histo_kde_bandwidth_method {
    HISTO_KDE_BANDWIDTH_SILVERMAN = 0,  /**< Silverman's rule of thumb: 0.9 * min(std, IQR/1.34) * n^(-1/5) [Default] */
    HISTO_KDE_BANDWIDTH_SCOTT     = 1,  /**< Scott's rule: 1.059 * std * n^(-1/5) */
    HISTO_KDE_BANDWIDTH_MANUAL    = 2   /**< Explicit user-provided bandwidth parameter */
} histo_kde_bandwidth_method_t;

/**
 * @brief Configuration options for KDE construction.
 */

bundled/include/histo/kde.h  view on Meta::CPAN

} histo_kde_options_t;

/**
 * @brief Opaque KDE model handle.
 */
typedef struct histo_kde histo_kde_t;

/**
 * @brief Returns the default KDE configuration options.
 *
 * Defaults: Gaussian kernel, Silverman bandwidth selector, bw_adjust = 1.0.
 *
 * @return Initialized histo_kde_options_t structure.
 */
histo_kde_options_t histo_kde_default_options(void);

/**
 * @brief Constructs a KDE model from an array of sample values and optional weights.
 *
 * @param[in] n       Number of samples (n >= 1).
 * @param[in] samples Array of finite sample values.



( run in 0.820 second using v1.01-cache-2.11-cpan-e623d60df62 )