{"_id":"gss","_rev":"13-aed63f566bd3e5cd2ef3b0cf3c803980","name":"gss","description":"Golden Section Search for javascript. (a line search technique used to minimize or maximize the output a function, also known as `argmax`).","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"gss","description":"Golden Section Search for javascript. (a line search technique used to minimize or maximize the output a function, also known as `argmax`).","version":"0.1.0","repository":{"type":"git","url":"git://github.com/DTrejo/gss.git"},"author":{"name":"David Trejo","email":"david+npm@dtrejo.com","url":"http://dtrejo.com/"},"main":"gss.js","directories":{"lib":"."},"engines":{"node":"*"},"licenses":[{"type":"MIT","url":"http://github.com/dtrejo/gss/raw/master/LICENSE"}],"_id":"gss@0.1.0","_engineSupported":true,"_npmVersion":"0.3.3","_nodeVersion":"v0.4.0","dist":{"shasum":"4719abea6938818adfb1e18db27fcb32cd72d3f8","tarball":"https://registry.npmjs.org/gss/-/gss-0.1.0.tgz","integrity":"sha512-G1ic+eUAHmzv3aXGlV8Xpgobw2DwDij2QbQju5wqNXKmoHQZraLPKNe71Uu5HJesJWgXDTk+loFKd7zIYRKpzw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDYDVrZiyOqw9GubOCqWQT4ZQi4z37oSiM6ysPlr51UCgIgETMdlVpPpU3AOfmCJW9nAnGX24ut0L57ptIeiOGjDSE="}]}},"0.1.1":{"name":"gss","description":"Golden Section Search for javascript. (a line search technique used to minimize or maximize the output a function, also known as `argmax`).","version":"0.1.1","repository":{"type":"git","url":"git://github.com/DTrejo/gss.git"},"author":{"name":"David Trejo","email":"david+npm@dtrejo.com","url":"http://dtrejo.com/"},"main":"gss.js","directories":{"lib":"."},"engines":{"node":"*"},"devDependencies":{"underscore":"~1.3.0"},"scripts":{"test":"node test/async.js && node test/sync.js"},"licenses":[{"type":"MIT","url":"http://github.com/dtrejo/gss/raw/master/LICENSE"}],"_npmUser":{"name":"dtrejo","email":"dtrejo@cs.brown.edu"},"_id":"gss@0.1.1","dependencies":{"underscore":"~1.3.0"},"_engineSupported":true,"_npmVersion":"1.1.0-beta-10","_nodeVersion":"v0.6.6","_defaultsLoaded":true,"dist":{"shasum":"e8088c318ca7607c08d72babea267442baa8dc1b","tarball":"https://registry.npmjs.org/gss/-/gss-0.1.1.tgz","integrity":"sha512-tBPfa+G4rhFCXqG667liLQ0OPxPq93P0ZuAqc508o4KpxWZCFxW8so5PkiCpEi9X+UZ051BNS3p7kePDGC60fw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFngt2ec9Qi34n8cy4mXKSFo+EZvfwHOngKMgHp3Slw+AiEAxC0kan++itSQO3Aes5NTRfeCRs0oUvyykzAvOTZ03bs="}]},"readme":"Golden Section Search\n===\n\nA line search technique to help you find the minimum or maximum of a function. I've adapted the version from [wikipedia](en.wikipedia.org/wiki/Golden_section_search) to support async functions as well as synchronous ones :)\n\nHow to use\n===\n\n    npm install gss\n\nThe arguments are a bit bad, but here's how you'd use it:\n\n    gss(asyncFunctionToMinimize, lowerBound, middleNumber, upperBound, precision, callback(err, min))\n  \n- `asyncFunctionToMinimize(x, cb)`: takes one argument, `x`, for which you are finding the argmax, and a callback that it calls when finished. It should call its callback like this: `cb(null, result)`.\n- `lowerBound`: a number you think makes a lower bound to the solution\n- `middleNumber`: any number between the upper and lower bounds\n- `upperBound`: a number you think makes an upper bound to the solution\n- `callback(err, min)`: a function to receive the results of the line search\n\nThe synchronous version takes a function that returns the result, and when it finishes it returns the result, so you don't need a callback. See the example below.\n\nAsync example:\n===\n\n    var gss = require('gss').gss\n\n    // f(x) = x^2\n    var f = function(x, cb) { cb(null, Math.pow(x, 2)); } \n\n    gss(f, -10, -7, 1, Math.sqrt(1e-10), function(err, min) {\n      //\n      // Now we have the min!\n      //\n      console.log(min, 'this should be prettty close to zero.');\n    });\n    \nSync example (you bad bad noder ;):\n\n      var gssSync = require('gss').gssSync\n      var f = function(x) { return Math.pow(x, 2); } // f(x) = x^2\n\n      var min = gssSync(_.memoize(f), -100, -50, 100, Math.sqrt(1e-10))\n      console.log(min, 'should be pretty darn close to zero.');\n\nGotchas\n===\nI recommend you use [`_.memoize`](http://documentcloud.github.com/underscore/#memoize) to make the minimization go as quickly as possible. If you'd like to maximize instead, have your function multiply by -1 before returning.\n\nTODOs:\n===\n- tests\n- automatically choose the `middleNumber`, to simplify API\n","maintainers":[{"name":"dtrejo","email":"dtrejo@cs.brown.edu"}]},"0.1.2":{"name":"gss","description":"Golden Section Search for javascript. (a line search technique used to minimize or maximize the output a function, also known as `argmax`).","version":"0.1.2","repository":{"type":"git","url":"git://github.com/DTrejo/gss.git"},"author":{"name":"David Trejo","email":"david+npm@dtrejo.com","url":"http://dtrejo.com/"},"maintainers":[{"name":"dtrejo","email":"dtrejo@cs.brown.edu"}],"main":"gss.js","directories":{"lib":"."},"engines":{"node":"*"},"devDependencies":{"underscore":"~1.3.0"},"scripts":{"test":"node test/async.js && node test/sync.js"},"licenses":[{"type":"MIT","url":"http://github.com/dtrejo/gss/raw/master/LICENSE"}],"dependencies":{},"optionalDependencies":{},"_npmUser":{"name":"dtrejo","email":"david.daniel.trejo@gmail.com"},"_id":"gss@0.1.2","_engineSupported":true,"_npmVersion":"1.1.18","_nodeVersion":"v0.6.14","_defaultsLoaded":true,"dist":{"shasum":"c2d86c8545d478feb41c4c88942cd9e929599bf1","tarball":"https://registry.npmjs.org/gss/-/gss-0.1.2.tgz","integrity":"sha512-2QW++Pmt6oq9IbyJWSvFVHdfUIHesHxXu4cNmh6uqwBI9+0f7RutApampjiPy4n6L1FongUesCq5ZBLB4Y2/jA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDTzvwCfo1mgxulkQcjFrO/EN35d2t0fjUr2xB0dVhHcwIgZspaI2DL5AQXIeZYKK5fAM9XbPHQdIoiVA3QNjnHboU="}]},"readme":"Golden Section Search\n===\n\nA line search technique to help you find the minimum or maximum of a function. I've adapted the version from [wikipedia](en.wikipedia.org/wiki/Golden_section_search) to support async functions as well as synchronous ones :)\n\nHow to use\n===\n\n    npm install gss\n\nThe arguments are a bit bad, but here's how you'd use it:\n\n    gss(asyncFunctionToMinimize, lowerBound, middleNumber, upperBound, precision, callback(err, min))\n  \n- `asyncFunctionToMinimize(x, cb)`: takes one argument, `x`, for which you are finding the argmax, and a callback that it calls when finished. It should call its callback like this: `cb(null, result)`.\n- `lowerBound`: a number you think makes a lower bound to the solution\n- `middleNumber`: any number between the upper and lower bounds\n- `upperBound`: a number you think makes an upper bound to the solution\n- `callback(err, min)`: a function to receive the results of the line search\n\nThe synchronous version takes a function that returns the result, and when it finishes it returns the result, so you don't need a callback. See the example below.\n\nAsync example:\n===\n\n    var gss = require('gss').gss\n\n    // f(x) = x^2\n    var f = function(x, cb) { cb(null, Math.pow(x, 2)); } \n\n    gss(f, -10, -7, 1, Math.sqrt(1e-10), function(err, min) {\n      //\n      // Now we have the min!\n      //\n      console.log(min, 'this should be prettty close to zero.');\n    });\n    \nSync example (you bad bad noder ;):\n\n      var gssSync = require('gss').gssSync\n      var f = function(x) { return Math.pow(x, 2); } // f(x) = x^2\n\n      var min = gssSync(_.memoize(f), -100, -50, 100, Math.sqrt(1e-10))\n      console.log(min, 'should be pretty darn close to zero.');\n\nGotchas\n===\nI recommend you use [`_.memoize`](http://documentcloud.github.com/underscore/#memoize) to make the minimization go as quickly as possible. If you'd like to maximize instead, have your function multiply by -1 before returning.\n\nTODOs:\n===\n- tests\n- automatically choose the `middleNumber`, to simplify API\n"}},"maintainers":[{"name":"dtrejo","email":"dtrejo@cs.brown.edu"}],"time":{"modified":"2022-06-18T16:25:06.878Z","created":"2011-03-01T03:47:06.612Z","0.1.0":"2011-03-01T03:47:06.728Z","0.1.1":"2012-01-12T00:24:36.457Z","0.1.2":"2012-04-27T19:18:35.852Z"},"author":{"name":"David Trejo","email":"david+npm@dtrejo.com","url":"http://dtrejo.com/"},"repository":{"type":"git","url":"git://github.com/DTrejo/gss.git"}}