awesome-sigmoid
Version:
generate sigmoid function flexible and easy
19 lines (18 loc) • 758 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeSigmoid = exports.sigmoid = void 0;
var sigmoid = function (x, gain) {
return (Math.tanh((gain * x) / 2) + 1) / 2;
};
exports.sigmoid = sigmoid;
var makeSigmoid = function (_a) {
var center = _a.center, deviation = _a.deviation, deviation_output = _a.deviation_output;
/*
see: https://www.wolframalpha.com/input/?i=solve+y+%3D+sigmoid((g)x)+for+g
variables: x: sigmoid input, y: sigmoid output, g: gain
*/
var gain = Math.log((-1 * deviation_output) / (deviation_output - 1)) / deviation;
return function (x) { return exports.sigmoid(x - center, gain); };
};
exports.makeSigmoid = makeSigmoid;
exports.default = exports.makeSigmoid;