npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

minimize-golden-section-1d

v3.0.0

Published

minimize-golden-section-1d

Downloads

574

Readme

minimize-golden-section-1d

Build Status npm version Dependency Status js-semistandard-style

Minimize a function of a single variable using golden section search

Introduction

Returns the argument that minimizes a function of a single variable using golden section search, a search algorithm similar to bisection search except that the size of the intervals is chosen so that function evaluations can be reused more effectively. The golden section works fine with discontinuities, asymptotes, or oscillations that would throw off derivative-based methods but is somewhat slower to converge, likely requiring more function evaluations.

Installation

$ npm install minimize-golden-section-1d

Example

Returns the argument that minimizes the function:

var minimize = require('minimize-golden-section-1d');

minimize(Math.cos)
// => 3.1415926622945616

minimize(Math.cos, {lowerBound: 0, upperBound: 1});
// => 1

minimize(Math.cos, {guess: -3});
// => -3.1415926432597825

Usage

require('minimize-golden-section-1d')(f[, options[, status]])

Given function f of one Number-valued variable, computes a local minimum. On successful completion, returns the value of the argument that minimizes f (note that this may either be a local or global minimum in the provided range). If the algorithm fails (i.e. if max iterations exceeded, NaN encountered, or unbounded divergence of the argument to Infinity), returns NaN.

If bounds are provided, this module proceeds immediately with golden section search. If upper, lower or both bounds are not provided, the algorithm will make use of an initial guess (a provided guess or just one of the bounds if that's all it has) and expand the search range until a minimum is bracketed.

Options:
  • tolerance [=1e-8]: Convergence tolerance. Algorithm continues until search interval is smaller than tolerance.
  • lowerBound [=-Infinity]: Lower bound of the search interval
  • upperBound [=Infinity]: Upper bound of the search interval
  • maxIterations [=100]: Maximum number of iterations for either bracketing or search phase.
  • guess [=0]: initial guess for unbounded minimization. Unused unless both upperBound and lowerBound are not provided.
  • initialIncrement [=1]: Initial interval by which to expand the search interval for unbounded minimization. Unused unless both upperBound and lowerBound are not provided.
Status:

If status object is provided, the following outputs are written in place:

  • status.converged (Boolean): true if algorithm succeeded
  • status.iterations (Number): number of iterations
  • status.minimum (Number): minimum value of the function achieved before exiting, whether the algorithm converged or not
  • status.argmin (Number): best guess of argmin achieved before exiting, whether the algorithm converged or not.

License

© 2015 Scijs. MIT License.

Authors

Ricky Reusser