6

From what I understand you use a sigmoid function to reduce a number to the range of 0-1.

Using the function found in this library

function sigmoid(z) {
  return 1 / (1 + Math.exp(-z));
}

This works for a numbers 1-36. Any number higher than this will just return 1.

sigmoid(36) -> 0.9999999999999998
sigmoid(37) -> 1
sigmoid(38) -> 1
sigmoid(9000) -> 1

How do you increase the range so this function can handle a number larger than 36.

Michael Warner
  • 3,879
  • 3
  • 21
  • 45
  • First divide your value by something first to make it smaller. Take a look at a graph of the sigmoid function. –  Feb 07 '19 at 18:38

2 Answers2

10

A sigmoid function is any function which has certain properties which give it the characteristic s-shape. Your question has many answers. For example, any function whose definition looks like

const k = 2;
function sigmoid(z) {
  return 1 / (1 + Math.exp(-z/k));
}

will fit the bill. The larger the k, the larger the useful domain.

John Coleman
  • 51,337
  • 7
  • 54
  • 119
4

A Sigmoid Function doesn't have bounds, that means it accept from infinitely small to infinitely large values.
Javascript, on the other hand, will round numbers (IEEE).

Anyway, what you can do is reescale your input before passing it to the formula.
Another option is tinker with the formula values, most notably the z value.

NemoStein
  • 2,088
  • 2
  • 22
  • 36