https://github.com/jamesplease/nearest-periodic-value.js
Find the nearest value of a discrete periodic function, given a point.
https://github.com/jamesplease/nearest-periodic-value.js
Last synced: 3 months ago
JSON representation
Find the nearest value of a discrete periodic function, given a point.
- Host: GitHub
- URL: https://github.com/jamesplease/nearest-periodic-value.js
- Owner: jamesplease
- License: mit
- Created: 2015-01-29T04:41:01.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-03T06:50:09.000Z (over 10 years ago)
- Last Synced: 2025-03-11T15:57:31.089Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 445 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nearest-periodic-value.js
[](https://travis-ci.org/jmeas/nearest-periodic-value.js)
[](https://codeclimate.com/github/jmeas/nearest-periodic-value.js)
[](https://codeclimate.com/github/jmeas/nearest-periodic-value.js)
[](https://david-dm.org/jmeas/nearest-periodic-value.js)
[](https://david-dm.org/jmeas/nearest-periodic-value.js#info=devDependencies)Find the nearest value of a discrete periodic function, given a point.
### What are discrete periodic functions?
Periodic functions are functions that repeat. Discrete functions are functions whose values do not
connect. An example of a discrete periodic function is the function of "Wednesdays" on a calendar.
Wednesdays are discrete values along a timeline, and they repeat every 7 days.### Terminology
The members of a periodic function's output are the "values." A single member is a "value."
The interval that the function repeats along is the "period."
A "point" is any value in the domain of the function.
### API
##### `nearestPeriodicValue(point, value, period)`
Find the nearest value to `point`. Supply a `value` from the codomain of the function, and its `period`.
### FAQ
**What if my point is equidistant between two values?**
The value in front of your point will be chosen.