| |
| import streamlit as st |
| import numpy as np |
| import matplotlib.pyplot as plt |
| from scipy.stats import norm |
| import plotly.graph_objects as go |
|
|
| |
| def Phi(z): |
| return norm.cdf(z) |
|
|
| def phi(z): |
| return norm.pdf(z) |
|
|
| |
| def F_BCNOLLN(y1, y2, mu1, sigma1, alpha1, beta1, mu2, sigma2, alpha2, beta2, lambd): |
| |
| z1 = (y1 - mu1) / sigma1 |
| z2 = (y2 - mu2) / sigma2 |
| |
| |
| H1_z1 = Phi(z1)**alpha1 + (1 - Phi(z1))**beta1 |
| H2_z2 = Phi(z2)**alpha2 + (1 - Phi(z2))**beta2 |
| |
| |
| term1 = (Phi(z1)*alpha1 / H1_z1)**(-lambd) |
| term2 = (Phi(z2)*alpha2 / H2_z2)**(-lambd) |
| term = term1 + term2 - 1 |
| cdf = term**(-1/lambd) |
| |
| return cdf |
|
|
| def f_BCNOLLN(y1, y2, mu1, sigma1, alpha1, beta1, mu2, sigma2, alpha2, beta2, lambd): |
| z1 = (y1 - mu1) / sigma1 |
| z2 = (y2 - mu2) / sigma2 |
| |
| H1_z1 = Phi(z1)**alpha1 + (1 - Phi(z1))**beta1 |
| H2_z2 = Phi(z2)**alpha2 + (1 - Phi(z2))**beta2 |
| |
| term1 = (Phi(z1)**alpha1 / H1_z1)**(-lambd) |
| term2 = (Phi(z2)**alpha2 / H2_z2)**(-lambd) |
| common_term = (term1 + term2 - 1)**(-(2*lambd + 1)/lambd) |
| |
| factor1 = (phi(z1) * Phi(z1)**(alpha1 - 1) * (1 - Phi(z1))**(beta1 - 1) * |
| (alpha1 + (beta1 - alpha1) * Phi(z1))) / (sigma1 * H1_z1**2) |
| |
| factor2 = (phi(z2) * Phi(z2)**(alpha2 - 1) * (1 - Phi(z2))**(beta2 - 1) * |
| (alpha2 + (beta2 - alpha2) * Phi(z2))) / (sigma2 * H2_z2**2) |
| |
| pdf = (lambd + 1) * common_term * (factor1 * factor2) |
| |
| return pdf |
|
|
| |
| st.title('BCNOLLN Distribution Visualizer') |
|
|
| |
| st.sidebar.title('Parameters') |
| st.sidebar.write('Adjust the parameters below to visualize the BCNOLLN distribution.') |
|
|
| |
| mu1 = st.sidebar.slider('Mean μ1', min_value=-10.0, max_value=10.0, value=0.0, step=0.1) |
| sigma1 = st.sidebar.slider('Standard deviation σ1', min_value=0.1, max_value=10.0, value=1.0, step=0.1) |
| alpha1 = st.sidebar.slider('Alpha1 α1', min_value=0.0, max_value=1.0, value=0.2, step=0.01) |
| beta1 = st.sidebar.slider('Beta1 β1', min_value=0.0, max_value=1.0, value=0.2, step=0.01) |
|
|
| mu2 = st.sidebar.slider('Mean μ2', min_value=-10.0, max_value=10.0, value=0.0, step=0.1) |
| sigma2 = st.sidebar.slider('Standard deviation σ2', min_value=0.1, max_value=10.0, value=1.0, step=0.1) |
| alpha2 = st.sidebar.slider('Alpha2 α2', min_value=0.0, max_value=1.0, value=0.9, step=0.01) |
| beta2 = st.sidebar.slider('Beta2 β2', min_value=0.0, max_value=1.0, value=0.3, step=0.01) |
|
|
| lambd = st.sidebar.slider('Lambda λ', min_value=-1.0, max_value=1.0, value=-0.5, step=0.01) |
|
|
|
|
| |
| y1, y2 = np.meshgrid(np.linspace(-10, 10, 100), np.linspace(-10, 10, 100)) |
|
|
| |
| pdf_values = f_BCNOLLN(y1, y2, mu1, sigma1, alpha1, beta1, mu2, sigma2, alpha2, beta2, lambd) |
|
|
| |
| cdf_values = F_BCNOLLN(y1, y2, mu1, sigma1, alpha1, beta1, mu2, sigma2, alpha2, beta2, lambd) |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| st.subheader('Results for PDF Plot') |
|
|
| |
| fig = go.Figure(data=[go.Surface(z=pdf_values, x=y1, y=y2, colorscale='Viridis')]) |
| fig.update_layout(title='BCNOLLN PDF 3D Contour Plot', autosize=True, |
| scene=dict( |
| xaxis_title='y1', |
| yaxis_title='y2', |
| zaxis_title='PDF' |
| )) |
|
|
| |
| st.plotly_chart(fig) |
|
|
| |
| fig, ax = plt.subplots() |
| contours = ax.contour(y1, y2, pdf_values, levels=20) |
| ax.clabel(contours, inline=True, fontsize=8, fmt='%.3f') |
|
|
| ax.set_xlabel('y1') |
| ax.set_ylabel('y2') |
| ax.set_title('BCEOLLN PDF Distribution Contour Plot') |
|
|
| |
| st.pyplot(fig) |
|
|
| |
| fig_2d, ax = plt.subplots() |
| cp = ax.contourf(y1, y2, pdf_values, cmap='viridis') |
| fig_2d.colorbar(cp) |
| ax.set_title('BCNOLLN PDF 2D Contour Plot') |
| ax.set_xlabel('y1') |
| ax.set_ylabel('y2') |
|
|
| |
| st.pyplot(fig_2d) |
|
|
|
|
| st.subheader('Results for CDF Plot') |
|
|
| |
| fig = go.Figure(data=[go.Surface(z=cdf_values, x=y1, y=y2, colorscale='Viridis')]) |
| fig.update_layout(title='BCNOLLN CDF 3D Contour Plot', autosize=True, |
| scene=dict( |
| xaxis_title='y1', |
| yaxis_title='y2', |
| zaxis_title='CDF' |
| )) |
|
|
| |
| st.plotly_chart(fig) |
|
|
| |
| fig, ax = plt.subplots() |
| contours = ax.contour(y1, y2, cdf_values, levels=20) |
| ax.clabel(contours, inline=True, fontsize=8, fmt='%.3f') |
|
|
| ax.set_xlabel('y1') |
| ax.set_ylabel('y2') |
| ax.set_title('BCEOLLN CDF Distribution Contour Plot') |
|
|
| |
| st.pyplot(fig) |
|
|
|
|
| |
| fig_2d, ax = plt.subplots() |
| cp = ax.contourf(y1, y2, cdf_values, cmap='viridis') |
| fig_2d.colorbar(cp) |
| ax.set_title('BCNOLLN CDF 2D Contour Plot') |
| ax.set_xlabel('y1') |
| ax.set_ylabel('y2') |
|
|
| |
| st.pyplot(fig_2d) |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
|
|
| |
|
|