Skip to main content
Ctrl+K
mlquantify homepage mlquantify homepage
  • Install
  • User Guide
  • API
  • Getting Started
  • About Us
  • GitHub
  • Install
  • User Guide
  • API
  • Getting Started
  • About Us
  • GitHub

Section Navigation

  • mlquantify
    • get_config
    • set_config
    • config_context
  • mlquantify.base
    • BaseQuantifier
    • MetaquantifierMixin
    • ProtocolMixin
  • mlquantify.base_aggregative
    • AggregationMixin
    • SoftPredictionMixin
    • CrispPredictionMixin
  • mlquantify.calibration
    • Calibrator
    • ClassifierCalibrator
    • QuantifierCalibrator
  • mlquantify.compose
    • BaseComposeQuantifier
    • LinearComposeQuantifier
    • LikelihoodComposeQuantifier
    • ComposeQuantifier
  • mlquantify.confidence
    • BaseConfidenceRegion
    • ConfidenceInterval
    • ConfidenceEllipseSimplex
    • ConfidenceEllipseCLR
    • construct_confidence_region
  • mlquantify.counting
    • CC
    • PCC
    • ThresholdAdjustment
    • TAC
    • TX
    • TMAX
    • T50
    • MS
    • MS2
    • FM
    • GACC
    • GPACC
    • evaluate_thresholds
    • compute_tpr
    • compute_fpr
    • compute_table
  • mlquantify.likelihood
    • CDE
    • EMQ
    • MLPE
  • mlquantify.losses
    • BaseLoss
    • DistanceLoss
    • LeastSquaresLoss
    • HellingerSurrogateLoss
    • EnergyLoss
    • NegativeLogLikelihoodLoss
    • MixtureNegativeLogLikelihoodLoss
    • RegularizedMixtureNLLLoss
    • normalize_distribution
    • get_loss
  • mlquantify.matching
    • BaseMatchingQuantifier
    • MatchingHistogramQuantifier
    • DyS
    • HDy
    • HDx
    • SORD
    • MatchingKernelQuantifier
    • MMD_RKHS
    • KDEyQuantifier
    • KDEyML
    • KDEyHD
    • KDEyCS
    • GKDEyML
    • GHDx
    • GHDy
    • SMM
    • EDy
    • EDx
  • mlquantify.meta
    • EnsembleQ
    • QuaDapt
    • AggregativeBootstrap
  • mlquantify.metrics
    • AE
    • SE
    • MAE
    • MSE
    • KLD
    • RAE
    • NAE
    • NRAE
    • NKLD
    • NMD
    • RNOD
    • VSE
    • CvM_L1
  • mlquantify.model_selection
    • GridSearchQ
    • BaseProtocol
    • APP
    • NPP
    • UPP
    • PPP
  • mlquantify.multiclass
    • binary_quantifier
    • BinaryQuantifier
  • mlquantify.neighbors
    • PWK
  • mlquantify.neural
  • mlquantify.representations
    • BaseRepresentation
    • HistogramRepresentation
    • KDERepresentation
    • DistanceRepresentation
    • KernelMeanRepresentation
    • PredictionRepresentation
    • HardPredictionRepresentation
    • SoftPredictionRepresentation
  • mlquantify.solvers
    • solve_binary
    • ternary_search
    • solve_simplex
    • minimize_prevalence
    • minimize_prevalence_blocks
  • mlquantify.utils
    • get_prev_from_labels
    • normalize_prevalence
    • load_quantifier
    • make_prevs
    • apply_cross_validation
    • simplex_uniform_kraemer
    • simplex_grid_sampling
    • simplex_uniform_sampling
    • get_indexes_with_prevalence
  • API Reference
  • mlquantify.solvers
  • ternary_search

ternary_search#

mlquantify.solvers.ternary_search(left, right, objective, tol=1e-06)[source]#

Find the minimum of a unimodal function via ternary search.

Iteratively narrows the interval [left, right] by comparing the objective at two interior probe points until the interval width falls below tol.

Parameters:
leftfloat

Left bound of the search interval.

rightfloat

Right bound of the search interval.

objectivecallable

Scalar function to minimize over [left, right]. Must be unimodal on the interval.

tolfloat, default=1e-6

Convergence criterion: the search stops when right - left <= tol.

Returns:
minimumfloat

Approximate location of the minimum.

Examples

>>> from mlquantify.solvers._binary import ternary_search
>>> minimum = ternary_search(0.0, 1.0, lambda x: (x - 0.3) ** 2)
>>> round(minimum, 4)
0.3

previous

solve_binary

next

solve_simplex

On this page
  • ternary_search
Show Source