# How to calculate gauss value

**URL:** <https://discuss.elastic.co/t/how-to-calculate-gauss-value/297106>\
**Category:** Elasticsearch\
**Tags:** eql-elastic-query-language\
**Created:** [February 14, 2022, 7:35am UTC](https://discuss.elastic.co/t/how-to-calculate-gauss-value/297106 "2022-02-14T07:35:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aniket\_Pant](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Aniket\_Pant](https://discuss.elastic.co/u/Aniket_Pant)\
**Post date:** [February 14, 2022, 7:35am UTC](https://discuss.elastic.co/t/how-to-calculate-gauss-value/297106/1 "2022-02-14T07:35:55Z")

</div>

I want to know how this gauss value is calculated.

```auto
POST sneaker/_search
{
  "query": {
    "function_score": {
      "functions": [
        {
          "gauss": {
            "price": {
              "origin": "300",
              "scale": "200"
            }
          }
        }
      ]
    }
  }
  , "explain": true
}

```

query result

```auto
 "_explanation" : {
          "value" : 1.0,
          "description" : "function score, product of:",
          "details" : [
            {
              "value" : 1.0,
              "description" : "*:*",
              "details" : []
            },
            {
              "value" : 1.0,
              "description" : "min of:",
              "details" : [
                {
                  "value" : 1.0,
                  "description" : "Function for field price:",
                  "details" : [
                    {
                      "value" : 1.0,
                     "description" : "exp(-0.5*pow(MIN[Math.max(Math.abs(300.0(=doc value) -300.0(=origin))) - 0.0(=offset), 0)],2.0)/28853.900817779268)",

"details" : []
                    }
                  ]
                },
              

```

Referring to this [Function score query doc](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#_supported_decay_functions)

> where ![sigma](https://us1.discourse-cdn.com/elastic/original/3X/3/7/37ed5bf56015ed3b9675d3825c1c3457ba787de6.png) is computed to assure that the score takes the value `decay` at distance `scale` from `origin` +- `offset`

![sigma calc](https://us1.discourse-cdn.com/elastic/original/3X/a/5/a5a3892c09ec9771db472f4f40c56747cbf2a7d7.png)

I want to know how this standard deviation value is calculated.

> "value" : 1.0,  
> "description" : "exp(-0.5\*pow(MIN[Math.max(Math.abs(300.0(=doc value) -300.0(=origin))) - 0.0(=offset), 0)],2.0)/28853.900817779268)",

How this `28853.900817779268` value is calculated

---

<div class="post-metadata">

**Author:** ![vincenbr](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@vincenbr](https://discuss.elastic.co/u/vincenbr)\
**Post date:** [February 15, 2022, 11:05am UTC](https://discuss.elastic.co/t/how-to-calculate-gauss-value/297106/2 "2022-02-15T11:05:16Z")

</div>

Hi, this is the direct application of the formula for sigma-square:  
decay is 0.5 (by default)  
your scale is 200  
so sigma-square is - (400^2) / ( 2 \* ln (0.5) )

---

<div class="post-metadata">

**Author:** ![Aniket\_Pant](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Aniket\_Pant](https://discuss.elastic.co/u/Aniket_Pant)\
**Post date:** [February 15, 2022, 11:13am UTC](https://discuss.elastic.co/t/how-to-calculate-gauss-value/297106/3 "2022-02-15T11:13:13Z")

</div>

It is solved in [this](https://stackoverflow.com/questions/71111773/how-to-calculate-gauss-value/71113838?noredirect=1#comment125726969_71113838)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 15, 2022, 11:13am UTC](https://discuss.elastic.co/t/how-to-calculate-gauss-value/297106/4 "2022-03-15T11:13:23Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
