# Standard deviation of Likelihood - sample size dependent?

**URL:** <https://discourse.pymc.io/t/standard-deviation-of-likelihood-sample-size-dependent/5882>\
**Category:** Questions\
**Created:** [October 1, 2020, 6:56am UTC](https://discourse.pymc.io/t/standard-deviation-of-likelihood-sample-size-dependent/5882 "2020-10-01T06:56:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![BjornHartmann](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@BjornHartmann](https://discourse.pymc.io/u/BjornHartmann)\
**Post date:** [October 1, 2020, 6:56am UTC](https://discourse.pymc.io/t/standard-deviation-of-likelihood-sample-size-dependent/5882/1 "2020-10-01T06:56:41Z")

</div>

Hi,  
I am really hoping someone may be able to help me figure out this simple issue:

I have some data-list (called obs) of length x, with a normal prior on the mean with parameters mu and sd, and a halfnormal prior on the standard deviation of the data, obs\_sd. I believe my data may be normally distributed, hence i have a normal likelihood function.  
Before specifying the data i then have the following model:

mu = 10  
sd = 2  
obs\_sd = 1

```
with pm.Model() as model:
    prior_m = pm.Normal('p_m', mu=mu, sd=sd)
    prior_sd = pm.HalfNormal('p_sd', sd=obs_sd)
    
    L = pm.Normal('L', mu=prior_mu, sd=prior_sd, observed = obs)

```

Here is my issue:  
If i have only one observed value in obs i get divergencies with this model, if i have two, or more, it seems to be fine. Also, if i set a known standard deviation on the likelihood, it seems to be fine with one variable.

So my question is: Is the lack of multiple observed values somehow affecting the posterior of the standard deviation of the likelihood? If so, why/how?

---

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [October 1, 2020, 3:24pm UTC](https://discourse.pymc.io/t/standard-deviation-of-likelihood-sample-size-dependent/5882/2 "2020-10-01T15:24:18Z")

</div>

Do you have problems with two observations? I would guess the problem is that the prior\_sd is unconstrained (other than by the prior) when you have a single observation. You are also trying to estimate two parameters from a single datapoint, which is usually problematic.

---

<div class="post-metadata">

**Author:** ![AlexAndorra](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/alexandorra/32/9142_2.png) [@AlexAndorra](https://discourse.pymc.io/u/AlexAndorra)\
**Post date:** [October 5, 2020, 4:40pm UTC](https://discourse.pymc.io/t/standard-deviation-of-likelihood-sample-size-dependent/5882/3 "2020-10-05T16:40:15Z")

</div>

Hi Bjorn,  
I think @ricardoV94’s answer is spot-on: you’re trying to estimate a standard deviation with one data point, which is impossible, so this is expected that NUTS spits out divergencies.  
Hope this helps 🖖

---

<div class="post-metadata">

**Author:** ![BjornHartmann](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@BjornHartmann](https://discourse.pymc.io/u/BjornHartmann)\
**Post date:** [October 6, 2020, 1:49pm UTC](https://discourse.pymc.io/t/standard-deviation-of-likelihood-sample-size-dependent/5882/4 "2020-10-06T13:49:26Z")

</div>

Thank you so much for answering @ricardoV94 and @AlexAndorra. It makes a lot of sense, and i am embarrased it wasnt obvious in the first place, heh.

I have problems with two observations depending on my confidence in my prior mean(?). If i set the sd of the prior mean to be 0.01 it seems to be ok, if i set it to be 1 or two, i am having divergencies.

---

<div class="post-metadata">

**Author:** ![AlexAndorra](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/alexandorra/32/9142_2.png) [@AlexAndorra](https://discourse.pymc.io/u/AlexAndorra)\
**Post date:** [October 15, 2020, 7:52am UTC](https://discourse.pymc.io/t/standard-deviation-of-likelihood-sample-size-dependent/5882/5 "2020-10-15T07:52:18Z")

</div>

This makes sense too: when you have very few data, the prior’s weight is more important in inference, so you have to use more informative priors if you wanna infer anything. That’s where domain knowledge enters the equation and allows you to choose sensible priors that will help inference, even when there isn’t much data
