Learn R Programming

fb4package (version 2.0.0)

binary_search_p_value: Binary search for optimal p_value

Description

Pure binary search algorithm for finding the p_value that achieves a target metric (final weight or total consumption).

Usage

binary_search_p_value(
  target_value,
  fit_type,
  lower_bound,
  upper_bound,
  simulation_function,
  tolerance = 0.001,
  max_iterations = 25
)

Value

List with fitted p_value and convergence information

Arguments

target_value

Target value (final weight or total consumption)

fit_type

Type of fitting ("weight" or "consumption")

lower_bound

Lower bound for p_value search

upper_bound

Upper bound for p_value search

simulation_function

Function that runs simulation and returns metric

tolerance

Tolerance for convergence

max_iterations

Maximum number of iterations