{"id":15646278,"url":"https://github.com/jonschlinkert/exponential-moving-average","last_synced_at":"2025-04-30T07:50:07.154Z","repository":{"id":65990679,"uuid":"87731985","full_name":"jonschlinkert/exponential-moving-average","owner":"jonschlinkert","description":"Calculate an exponential moving average from an array of numbers.","archived":false,"fork":false,"pushed_at":"2020-01-08T23:43:42.000Z","size":10,"stargazers_count":49,"open_issues_count":0,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-30T07:49:58.574Z","etag":null,"topics":["array","average","calculate","exponential-moving-average","math","moving-average","numbers"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-09T18:58:48.000Z","updated_at":"2023-09-21T08:03:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"51eaf991-bd68-49d9-8376-f1bb16807f94","html_url":"https://github.com/jonschlinkert/exponential-moving-average","commit_stats":{"total_commits":5,"total_committers":2,"mean_commits":2.5,"dds":0.4,"last_synced_commit":"48cbdf1d934599011f440965867f19b6151dc4e2"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fexponential-moving-average","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fexponential-moving-average/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fexponential-moving-average/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fexponential-moving-average/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/exponential-moving-average/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251666227,"owners_count":21624291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","average","calculate","exponential-moving-average","math","moving-average","numbers"],"created_at":"2024-10-03T12:12:11.796Z","updated_at":"2025-04-30T07:50:07.128Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","readme":"# exponential-moving-average [![NPM version](https://img.shields.io/npm/v/exponential-moving-average.svg?style=flat)](https://www.npmjs.com/package/exponential-moving-average) [![NPM monthly downloads](https://img.shields.io/npm/dm/exponential-moving-average.svg?style=flat)](https://npmjs.org/package/exponential-moving-average)  [![NPM total downloads](https://img.shields.io/npm/dt/exponential-moving-average.svg?style=flat)](https://npmjs.org/package/exponential-moving-average) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/exponential-moving-average.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/exponential-moving-average)\n\n\u003e Calculate an exponential moving average from an array of numbers.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save exponential-moving-average\n```\n\n## Usage\n\n```js\nvar ema = require('exponential-moving-average');\n\nvar arr = [\n  '22.27', \n  '22.19', \n  '22.08', \n  '22.17', \n  '22.18', \n  '22.13', \n  '22.23', \n  '22.43', \n  '22.24', \n  '22.29', \n  '22.15', \n  '22.39', \n  '22.38', \n  '22.61', \n  '23.36', \n  '24.05', \n  '23.75', \n  '23.83', \n  '23.95', \n  '23.63', \n  '23.82', \n  '23.87', \n  '23.65', \n  '23.19', \n  '23.10', \n  '23.33', \n  '22.68', \n  '23.10', \n  '22.40', \n  '22.17'\n];\n\n// calculate ema over 10 days\nconsole.log(ema(arr, 10));\n```\nResults in:\n\n```js\n[\n  '22.22',\n  '22.21',\n  '22.24',\n  '22.27',\n  '22.33',\n  '22.52',\n  '22.80',\n  '22.97',\n  '23.13',\n  '23.28',\n  '23.34',\n  '23.43',\n  '23.51',\n  '23.53',\n  '23.47',\n  '23.40',\n  '23.39',\n  '23.26',\n  '23.23',\n  '23.08',\n  '22.92'\n]\n```\n\n## Options\n\nOptions may be passed as an object or as a number to specify only the [range](#range) to use.\n\n### range\n\nThe number of array elements to use for the moving average. If no number is specified half of the length of the array is used.\n\n**Example**\n\n```js\nema(arr, 10);\n// or\nema(arr, {range: 10});\n```\n\n### format\n\nFormat the numbers as they're added to the result.\n\n```js\nema(arr, {\n  format: function(num) {\n    return num.toFixed(3);\n  }\n});\n```\n\n## About\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n### Building docs\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 09, 2017._","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fexponential-moving-average","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fexponential-moving-average","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fexponential-moving-average/lists"}