nearest-periodic-value
Version:
Find the nearest value of a discrete periodic function, given a point.
35 lines (21 loc) • 1.72 kB
Markdown
# 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.