# Logistic Function Challenge

**URL:** https://openfhe.discourse.group/t/logistic-function-challenge/887
**Category:** FHE Challenges
**Created:** [November 7, 2023, 8:02pm UTC](https://openfhe.discourse.group/t/logistic-function-challenge/887 "2023-11-07T20:02:07Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)
#### Post date: [November 7, 2023, 8:02pm UTC](https://openfhe.discourse.group/t/logistic-function-challenge/887/1 "2023-11-07T20:02:07Z")

</div>

This topic for discussions on the Logistic Function challenge posted at [https://fherma.io/challenges](https://fherma.io/challenges)

---

<div class="post-metadata">

### Author: ![john](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@john](https://openfhe.discourse.group/u/john)
#### Post date: [November 9, 2023, 11:17am UTC](https://openfhe.discourse.group/t/logistic-function-challenge/887/2 "2023-11-09T11:17:32Z")

</div>

Hello!  
I would like to take part in this challenge.  
Is bootstrapping allowed? If yes where can I find the bootstrapping keys?

---

<div class="post-metadata">

### Author: ![MIke128](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@MIke128](https://openfhe.discourse.group/u/MIke128)
#### Post date: [November 9, 2023, 11:41am UTC](https://openfhe.discourse.group/t/logistic-function-challenge/887/3 "2023-11-09T11:41:39Z")

</div>

Hi!  
Is it allowed to use Chebyshev approximation implemented in OpenFHE to solve this challenge?

---

<div class="post-metadata">

### Author: ![gurgen](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@gurgen](https://openfhe.discourse.group/u/gurgen)
#### Post date: [November 9, 2023, 4:39pm UTC](https://openfhe.discourse.group/t/logistic-function-challenge/887/4 "2023-11-09T16:39:23Z")

</div>

Hello John! For this particular challenge, we assume that bootstrapping will not be used.  
However, it will be allowed for some other challenges in the future.

---

<div class="post-metadata">

### Author: ![gurgen](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@gurgen](https://openfhe.discourse.group/u/gurgen)
#### Post date: [November 9, 2023, 4:48pm UTC](https://openfhe.discourse.group/t/logistic-function-challenge/887/5 "2023-11-09T16:48:07Z")

</div>

Hello Mike128,

Of course, you can use any available methods.

---

<div class="post-metadata">

### Author: ![Pro7ech](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/pro7ech/32/301_2.png) [@Pro7ech](https://openfhe.discourse.group/u/Pro7ech)
#### Post date: [November 9, 2023, 8:25pm UTC](https://openfhe.discourse.group/t/logistic-function-challenge/887/6 "2023-11-09T20:25:17Z")

</div>

How is the accuracy actually computed? I understand that it is a value in [0, 1] but it is not clear how |f(x) - g(x)| is mapped to this interval. Is the mapping using as reference for the normalization the maximum possible precision enabled by the scheme parameters?

---

<div class="post-metadata">

### Author: ![gurgen](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@gurgen](https://openfhe.discourse.group/u/gurgen)
#### Post date: [November 9, 2023, 10:03pm UTC](https://openfhe.discourse.group/t/logistic-function-challenge/887/7 "2023-11-09T22:03:29Z")

</div>

The overall accuracy is determined based on the accuracy in each slot.  
The slot accuracy is based on the double-precision accuracy in the clear and is unrelated to maximum CKKS precision. For the slot v\_i accuracy is evaluated using the following formula:  
\text{accuracy}(v\_i) = \begin{cases} 1 - \text{relative\_error}(v\_i) & \text{if } 1 - \text{relative\_error}(v\_i) \geq threshold \\ 0 & \text{else} \end{cases}  
\text{relative\_error}(v\_i) is an relative error evaluated based on expected and received values,  
threshold is a challenge-dependent parameter. For Logistic Function challenge threshold = 0.8

---

<div class="post-metadata">

### Author: ![Pro7ech](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/pro7ech/32/301_2.png) [@Pro7ech](https://openfhe.discourse.group/u/Pro7ech)
#### Post date: [November 9, 2023, 11:24pm UTC](https://openfhe.discourse.group/t/logistic-function-challenge/887/8 "2023-11-09T23:24:21Z")

</div>

And what is the formula for \text{relative\_error} ? Is it \tfrac{|a\_i-b\_i|}{\max(|a|)} ? For a the expected values and b the received values.

---

<div class="post-metadata">

### Author: ![gurgen](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@gurgen](https://openfhe.discourse.group/u/gurgen)
#### Post date: [November 9, 2023, 11:49pm UTC](https://openfhe.discourse.group/t/logistic-function-challenge/887/9 "2023-11-09T23:49:08Z")

</div>

For the expected value a and the received value b, if a\_i \neq 0

relative\_error(b\_i) = \frac{|a\_i -b\_i|}{|a\_i|}

if a\_i =0

relative\_error(b\_i) = \begin{cases} |b\_i| & \text{if } 0 \leq|b\_i| \<1 \\ 1 & \text{else} \end{cases}

---

<div class="post-metadata">

### Author: ![Pro7ech](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/pro7ech/32/301_2.png) [@Pro7ech](https://openfhe.discourse.group/u/Pro7ech)
#### Post date: [November 10, 2023, 7:21am UTC](https://openfhe.discourse.group/t/logistic-function-challenge/887/10 "2023-11-10T07:21:20Z")

</div>

Thanks! Interesting choice to choose not to take into account that CKKS is fixed point arithmetic.

---

<div class="post-metadata">

### Author: ![gurgen](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@gurgen](https://openfhe.discourse.group/u/gurgen)
#### Post date: [November 10, 2023, 10:47am UTC](https://openfhe.discourse.group/t/logistic-function-challenge/887/11 "2023-11-10T10:47:55Z")

</div>

Hi @Pro7ech,  
I realized that I provided the incorrect formula for the relative error for Logistic Function Challenge above.  
For Logistic Function we estimate relative error, as you mentioned earlier, because otherwise for small values the error would always be large, so  
 relative\_error (b\_i)= \frac{|a\_i-b\_i|}{max(|a|)}
