## 5 Two-Parameter Family of Densities with Different Degrees of Smoothness
### Modeling Random Variables with Given Test Distributions Using Monte Carlo Method  
The modeling formula for the random variable \(\xi\) with distribution function \(f_{v_{1},v_{2}}\) for parameters \(v_{1}\) and \(v_{2}\) can be derived using the inverse function method [22]: \(\xi=f_{v_{1},v_{2}}^{-1}(\alpha)\), where \(f_{v_{1},v_{2}}^{-1}\) is the inverse function to \(f_{v_{1},v_{2}}\) and \(\alpha\) is the random variable having a uniform distribution on \((0,1)\). Given the distribution function \(f_{v_{1},v_{2}}\), we can obtain the Algorithm 3 for modeling the random variable \(\xi\). ```
0. Set parameters \(v_{1}\), \(v_{2}\), calculate \(\gamma_{v_{1},v_{2}}\) and \(f_{v_{1},v_{2}}(0)\): \[\gamma_{v_{1},v_{2}}=\biggl{(}\frac{v_{1}}{v_{1}+1}+\frac{v_{2}}{v_{2}+1} \biggr{)}^{-1},\ \ f_{v_{1},v_{2}}(0)=\gamma_{v_{1},v_{2}}\,\frac{v_{1}}{v_{1}+1}=\frac{v_{1} (v_{2}+1)}{v_{1}+2v_{1}v_{2}+v_{2}}.\]
1. Obtain a realization of the random variable \(\alpha\) having a uniform distribution on \((0,1)\). 2. If \(\alpha<f_{v_{1},v_{2}}(0)\), then \(\xi\) is a root of the algebraic equation \[\frac{v_{1}}{v_{1}+1}+x+\frac{(-x)^{v_{1}+1}}{v_{1}+1}-\frac{\alpha}{\gamma_{ v_{1},v_{2}}}=0\] (33) from \((-1,0)\), otherwise \(\xi\) is a root of the algebraic equation \[\frac{v_{1}}{v_{1}+1}+x-\frac{x^{v_{2}+1}}{v_{2}+1}-\frac{\alpha}{\gamma_{v_{1},v_{2}}}=0\] (34) from \([0,1)\). ```  
**Algorithm 3**Modeling the random variable with given test density and distribution function. For small \(v_{1}\) and \(v_{2}\), roots can be found analytically. Next, we obtain the modeling formulae for two cases used below. **Proposition 1**: _For the random variable \(\xi\) with density_  
\[g(x)=\frac{6}{7}\left\{ \begin{array}{ll}1+x&\text{for }x\in[-1,0),\\ 1-x^{2}&\text{for }x\in[0,1],\\ 0&\text{otherwise,}\end{array} \right.\]the modeling formula is as follows:_  
\[\xi=\left\{ \begin{array}{ll}\sqrt{\frac{7\alpha}{3}}-1&\text{for $\alpha<\frac{3}{7}$},\\ -\operatorname{Re}A+\sqrt{3}\,\operatorname{Im}A&\text{for $\alpha\geqslant\frac{3}{7}$}, \end{array} \right. \tag{35}\]  
_where_  
\[A=\sqrt[3]{\frac{3-7\alpha}{4}+\sqrt{\frac{(7\alpha-3)^{2}}{16}-1}}.\]  
Proof. : The density \(g\) of the random variable \(\xi\) is included in a two-parameter family (30) for \(v_{1}=v\), \(v_{2}=v+1\), and \(v=1\): \(g=g_{1,2}\). For given parameters, we have  
\[\frac{v_{1}}{v_{1}+1}=\frac{1}{2},\ \ \ \gamma_{1,2}=\frac{6}{7},\ \ \ f_{1,2}(0)=\frac{3}{7}.\]  
First, we consider the case \(\alpha<f_{1,2}(0)=3/7\); i.e., we should solve Equation (33). This is the quadratic equation  
\[\frac{1}{2}+x+\frac{x^{2}}{2}-\frac{7\alpha}{6}=0,\ \ \ \text{or}\ \ \ x^{2}+bx+c=0,\]  
where \(b=2\), \(c=1-7\alpha/3>0\). The function \(v(x)=x^{2}+2x+1-7\alpha/3\) has a minimum at \(x^{*}=-1\) since \(v^{\prime}(x^{*})=2x^{*}+2=0\), \(v^{\prime\prime}(x^{*})=2>0\) and \(v(x^{*})=-7\alpha/3<0\). This means that the quadratic equation has two real roots (the discriminant is positive) and the largest of them determines \(\xi\):  
\[\xi=\max\{x_{1},x_{2}\}>x^{*},\ \ \ x_{1,2}=-\frac{b}{2}\pm\sqrt{\frac{b^{2}}{4}-c} =-1\pm\sqrt{\frac{7\alpha}{3}},\ \ \ \xi=\sqrt{\frac{7\alpha}{3}}-1\in(-1,0).\]  
Second, we consider the case \(\alpha\geqslant f_{1,2}(0)=3/7\); i.e., we should solve Equation (34). This is the cubic equation  
\[\frac{1}{2}+x-\frac{x^{3}}{3}-\frac{7\alpha}{6}=0,\ \ \ \text{or}\ \ \ x^{3}+px+q=0,\]  
where \(p=-3,q=(7\alpha-3)/2>0\). The function \(w(x)=x^{3}-3x+(7\alpha-3)/2\) has extrema at \(x_{1,2}^{*}=\pm 1\): \(w^{\prime}(x^{*})=3(x_{1,2}^{*})^{2}-3=0\). A minimum is reached at \(x_{1}^{*}=1\): \(w^{\prime\prime}(x_{1}^{*})=6x_{1}^{*}=6>0\) and \(w(x_{1}^{*})=7(\alpha-1)/2<0\). A maximum is reached at \(x_{2}^{*}=-1\): \(w^{\prime\prime}(x_{2}^{*})=6x_{2}^{*}=-6<0\) and \(w(x_{2}^{*})=(1+7\alpha)/2>0\). This means that the cubic equation has three real roots (the discriminant is positive) and \(\xi\) is determined by the root that lies between the smallest and the largest roots.