> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# $sigmoid  (expression operator)

## Definition

Performs the sigmoid function, which calculates the percentile of a number in the normal distribution with standard deviation 1.

The [`$sigmoid`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/sigmoid.md#mongodb-expression-exp.-sigmoid) expression has the following syntax:

```javascript
{ $sigmoid: { input: <numeric expression>, onNull: <expression>} }
```

The arguments can be any valid [expression](https://www.mongodb.com/docs/manual/reference/mql/expressions.md#std-label-aggregation-expressions) as long as they resolve to all numbers.

The sigmoid function is equivalent to the following algebraic operation:

![The sigmoid function](/images/sigmoid.png)

## Example

This example uses a `myScores` collection that contains the following documents:

```javascript
db.myScores.insertMany( [
   { score: 1 },
   { score: 5 },
   {},
   { score: 13 },
   { score: null },
   { score: 21 },
] )
```

The following aggregation pipeline adds a `scaled` field to each document and uses `$sigmoid` to calculate the `scaled` field value:

```javascript
db.myScores.aggregate( [
   { $set: {
      scaled: { $sigmoid: "$score" }
   } }
] )
```

The operation returns the following documents:

```javascript
{ score: 1, scaled: 0.7310585786 }
{ score: 5, scaled: 0.9933071491 }
{ scaled: null }
{ score: 13, scaled: 0.9999977397 }
{ score: null, scaled: null }
{ score: 19, scaled: 0.9999999992 }
```
