# Difference between revisions of "User:Lchrisman/JQPN Cowlick"

This page has notes by Lonnie on an oddity that I've named the "Cowlick" of the fully-bounded Johnson QPN distribution from the paper:

This oddity impacts the implementation of DensUncertainLMH, where I was hoping to use their algorithm but ran into this glitch. Other than this, I am enthusiastic about their paper and am hoping to use their algorithm. I want to have a robust built-in function in Analytica, but I need to explore whether this is something that needs to be fixed first. So this page contains my private notes, just so I can understand what is going on, perhaps find a fix.

The cowlick refers to an artifact in their fully-bounded distribution in which the density goes to infinity at the upper and lower bounds. At first I thought it happened at the upper bound when n=1 (when B < ave(L,H)), or goes to infinity at the lower bound when n=-1 (when B>ave(L,H)). But results below (in the absence of a mistake on my part) show that it is always there. (In the less extreme cases, the spike is so thin that you can only detect it by zeroing in very closely around the bound). This is an undesirable trait, and causes there to be what is essentially a step in the CDF at the upper bound, as if the continuous part of the CDF doesn't really go to the upper bound. It isn't a step in a strict sense (it is continuous), but it flicks up so fast at the end that it acts like a step. It would be better if it tended to ease up to the bound more smoothly. I think there are extreme cases where it would need to approach an infinite slope at the bounds (like where the 90th percentile gets arbitrarily close to the UB), but I'm seeing it were that doesn't seem necessary.

The figure here is the cowlick in the illustrative example from their paper, where you can see the density jumping to infinity at the upper bound. This graph is the same as the graph that appears in their paper as Figure 7b, where you can make out this phenomena if you look carefully. Here is their graph with my arrow pointing out the start of the cowlick. The CDF for the distribution parameterized by (-11, -10, -9.99, -9, -8) is shown next, where the cowlick causes a "step" to occur in the CDF at the upper bound. It isn't quite the smooth CDF I had hoped for. The paper doesn't acknowledge this oddity, but it can be detected in their Figure 7b at the upper bound. The oddity does not happen with the unbounded and semi-bounded cases.

## Cowlick ubiquity

Although the cowlick was quite obvious after I had implemented the algorithm, I found it to be non-trivial to prove that it happens. This is my attempt. I focus just on the upper bound first.

Theorem: In the fully-bounded Hadlock & Bickel JQPN distribution, the probability density $f_B$ at the upper bound $u$ and at the lower bound approaches infinity (in all cases) -- i.e.,
$\lim_{x\rarr u} f_B(x) = \infty$
where $f_B(x) = {{\partial F_B(x)}\over{\partial x}}$ and $F_B(x)$ is the cumulative probability function given in Eq (8) of the paper.

### Proof of the theorem

In the paper, the quantile function $Q_B(p)$ is the inverse of the cumulative probability function $F_B(x)$, where $x=l$ corresponds to $p=0$ and $x=u$ occurs when $p=1$. Hence, the derivative of $F_B(x)$ is the reciprocal of $Q_B(p)$ at the corresponding $p$. Since the equations are a little simpler for the derivative of $Q_B$, what I'll actually be showing is that when $B<(H+L)/2$

$\lim_{p->1} {{\partial Q_B(p)}\over{\partial p}} = 0$

which, one shown, will establish that $f_B(u)$ approaches $\infty$.

$Q_B$ is defined in Eq (7) of the paper as

$Q_B(p) = l + (u-l) \Phi\left( \xi+ \lambda \sinh( \delta (\Phi^{-1}(p) + n c)) \right)$

where $l, u$ are the specified lower and upper bounds for the bounded distribution, $\Phi(x)$ is the standard normal cumulative probability function, and $\xi, \lambda, \delta, n$ and $c$ are defined in the paper as a function of the distribution parameters.

From their definitions, $c>0, \delta>0, \lambda>0$ always. When $B<(L+H)/2$ as assumed by the theorem, by definition $n=1$. The proof does not require more precision that this. (For the proof of the lower bound when $B>(L+H)/2$, $n=-1$).

To simplify notation, I make this variable substitution:

$z = \delta( \Phi^{-1}(p) + n c)$

yielding

$Q_B(z) = l + (u-l) \Phi\left( \xi+ \lambda \sinh( z ) \right)$

and

${{\partial Q_B(p)}\over{\partial p}} = {{\partial Q_B(z)}\over{\partial z}} {{\partial z}\over{\partial p}} = {{\partial Q_B(z)}\over{\partial z}} \sqrt{2\pi} \delta e^{{1\over 2} \Phi^{-1}(p)^2 } = {{\partial Q_B(z)}\over{\partial z}} \sqrt{2\pi} \delta e^{{1\over 2}(z/\delta - n c)^2}$

where $x\rarr u$ corresponds to $p\rarr 1$ and $z \rarr \infty$, so

$\lim_{p->1} {{\partial Q_B(p)}\over{\partial p}} = \lim_{z\rarr \infty} \sqrt{2\pi} \delta e^{{1\over 2} (z/\delta - n c)^2} {{\partial Q_B(z)}\over{\partial z}}$

and

$\lim_{p->} {{\partial Q_B(p)}\over{\partial p}} = \lim_{z\rarr \infty} \sqrt{2\pi} \delta e^{{1\over 2}(z/\delta - n c)^2} {{\partial Q_B(z)}\over{\partial z}}$

and we need to show that these approach 0.

Take the derivative (I used Wolfram Alpha's online derivative calculator):

${{\partial Q_B(z)}\over{\partial z}} = {{(u-l) \lambda}\over{2 \sqrt{2 \pi}}} \left( e^z + e^{-z} \right) e^{-{1\over 2} \left( {1\over 2} \lambda \left(e^z - e^{-z}\right) + \xi\right)^2}$

Expand the limit

$\begin{array}{rcl} \lim_{p\rarr 1} {{\partial Q_B(p)}\over{\partial p}} &=& \lim_{z\rarr \infty} \sqrt{2\pi} \delta e^{{1\over 2}(z/\delta- n c)^2} {{\partial Q_B(z)}\over{\partial z}} \\ &=& \lim_{z\rarr \infty} \sqrt{2\pi} \delta e^{{1\over 2}(z/\delta - n c)^2} {{(u-l) \lambda}\over{2 \sqrt{2 \pi}}} \left( e^z + e^{-z} \right) e^{-{1\over 2} \left( {1\over 2} \lambda \left(e^z - e^{-z}\right) + \xi\right)^2} \\ &=& {1\over 2} (u-l)\delta \lambda \left( \lim_{z\rarr \infty} e^z + e^{-z} \right) \left( \lim_{z\rarr \infty} e^{{1\over 2} (z/\delta- n c)^2} \right) \left( \lim_{z\rarr \infty} e^{-{1\over 2} \left( {1\over 2} \lambda \left( e^z - e^{-z}\right) + \xi\right)^2} \right) \\ &=& {1\over 2} (u-l)\delta \lambda \left( \lim_{z\rarr \infty} e^z \right) \left( \lim_{z\rarr \infty} e^{{1\over 2} \delta^{-2} z^2} \right) \left( \lim_{z\rarr \infty} e^{-{1\over 4} \lambda^2 {e^z}^2} \right) \\ &=& {1\over 2} (u-l)\delta \lambda \lim_{z\rarr \infty} e^z e^{{1\over 2} \delta^{-2} z^2} e^{-{1\over 4} \lambda^2 e^{z^2}} \\ &=& 0 \end{array}$

Last line follows because the $e^{-{1\over4} \lambda^2 e^{z^2}}$ term goes to zero and dominates both $e^z$ and $e^{{1\over 2}\delta^{-2} z^2}$.

Note: I did not use the fact that $n=1$, so the same proof works for $z \rarr -\infty$, which if correct would mean that the cowlick appears on both bounds always. However, this is not what I observe. So something is not quite right yet.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8257273,"math_prob":0.9995394,"size":8285,"snap":"2020-10-2020-16","text_gpt3_token_len":2631,"char_repetition_ratio":0.14515156,"word_repetition_ratio":0.20144928,"special_character_ratio":0.34025347,"punctuation_ratio":0.073529415,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9999585,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,3,null,3,null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-03-28T17:04:48Z\",\"WARC-Record-ID\":\"<urn:uuid:c804c62b-a901-4728-9fea-85c90bbc01bd>\",\"Content-Length\":\"32903\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fd92d64a-19eb-4cda-96a9-4f365032cf8b>\",\"WARC-Concurrent-To\":\"<urn:uuid:2018eb65-da0b-419c-9843-cd5ab7218206>\",\"WARC-IP-Address\":\"132.148.7.181\",\"WARC-Target-URI\":\"https://wiki.analytica.com/index.php?title=User%3ALchrisman/JQPN_Cowlick&diff=prev&oldid=54096\",\"WARC-Payload-Digest\":\"sha1:NRLQCHZKUSMOI5AIGP5SFZK6TRA4E4HC\",\"WARC-Block-Digest\":\"sha1:5G522C5TVXK6FXIFDGTMFANFH4UOD3IG\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-16/CC-MAIN-2020-16_segments_1585370492125.18_warc_CC-MAIN-20200328164156-20200328194156-00114.warc.gz\"}"}