rStats.js v1.3.0
    Preparing search index...

    Function optimize

    • Minimum (or maximum) of a function of one variable on an interval, by Brent's golden-section and parabolic search. Equivalent to R's optimize(). optimum is the location (R's minimum/maximum) and objective the function there. lower and upper must be finite and lower less than upper, as in R.

      Parameters

      • f: (x: number) => number
      • lower: number
      • upper: number
      • options: OptimizeOptions = {}

      Returns { objective: number; optimum: number }

      • objective: number

        Value of the function there.

      • optimum: number

        Location of the minimum or maximum (R's minimum or maximum).

      optimize((x) => (x - 1 / 3) ** 2, 0, 1).optimum; // 0.3333333333333333