Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
atlas-cubic-smoothing
Advanced tools
A commonly used cubic smoothing function for values in the domain [0,1].
A commonly used cubic smoothing function for values in the domain [0,1].
npm install --save atlas-cubic-smoothing
When generating values between an interval, it can be helpful to use a smoothing function to ease values which are close to the endpoints of the interval.
The smoothing function used here is a 3rd order polynomial of the form:
const smooth = require("atlas-cubic-smoothing");
// create a vector of input values
const inputs = [];
for (let x = 0; x <= 1; x+=.001) inputs.push(x);
// apply smoothing
const smoothed = inputs.map(x => smooth(x));
Your output values will fall along the following curve:
Smoothing works by changing how the input values change over their interval. For example, x = .01
and x = .02
are delta = .01
units away from each other. When these values are smoothed, they are squeezed together in the output space.
For many smoothing functions (including this one), values in the center of the input range are spread apart. For example x = .50
and x = .51
are delta = .01
units away from each other. However, when they are smoothed, they are almost twice as far away in the output space. Higher order smoothing functions tend to squeeze and stretch values to a greater extent.
A derivative is just a fancy way to say "slope" at some point in our function. First, recall that the derivative of f(x) = x
is 1
, meaning its slope never changes as a function of x
. To understand whether values will be squeezed or stretched in the output space, we can take the first derivative of the smoothing function:
We want to ask ourselves whether or not the smoothing function will squeeze or stretch our input values at a certain point. All we need to do is plug our point into the derivative above. For example, plugging in the point x = .1
tells us that the derivative is s'(.1) = .54
, meaning it grows at roughly half the rate of f(x) = x
at the same point (hence, squeezing). If we input x = .5
, we'll find that the derivative is s'(.5) = 1.5
, which means it grows 50% faster in the center than f(x) = x
(hence, stretching).
Another interesting property of smoothing functions is that they tend to have even derivatives around the center of the input interval, meaning that values will be smoothed symmetrically around the middle (x = .5
, in this case). If you transform coordinates of the smoothing function such that a = x - .5
, you'll find that the derivative of the result is even, or that s'(a) = s'(-a)
.
The exported function should take input in the range [0,1]
, otherwise it doesn't make much sense for smoothing. Be sure to normalize your input!
FAQs
A commonly used cubic smoothing function for values in the domain [0,1].
We found that atlas-cubic-smoothing demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.