# Introduction to NTLKwIEx

This vignette provides an overview of the “NTLKwIEx” package. The package NTLKwIEx offers a powerful range of statistical tools for analysis,simulation, and computation based on the Topp-Leone Kumaraswamy Inverse Exponential (NTLKwIEx) distribution. This distribution, which combines the properties of the Topp-Leone, Kumaraswamy, a new proposal and inverse exponential distributions,is particularly useful for modeling complex, heterogeneous data present in many scientific disciplines. With the “NTLKwIEx” package, users can estimate the parameters of the NTLKwIEx distribution from datasets, generate random samples according to this distribution, plot histograms and density functions, and calculate specific quantiles.

## Installation

You can install the “NTLKwIEx” package from CRAN using the following command:

install.packages("ggplot2")
install.packages("dplyr")
install.packages("NTLKwIEx")

library(stats)
library(dplyr)
#> Warning: le package 'dplyr' a été compilé avec la version R 4.2.3
#>
#> Attachement du package : 'dplyr'
#> Les objets suivants sont masqués depuis 'package:stats':
#>
#>     filter, lag
#> Les objets suivants sont masqués depuis 'package:base':
#>
#>     intersect, setdiff, setequal, union
library(ggplot2)
library(NTLKwIEx)

## Overview of NTLKwIEx distribution

The distribution is particularly useful for modeling data with heavy tails, skewness, and positive values. It is a versatile distribution that can handle diverse characteristics in the data.

## Probability density function (PDF) for NTLKwIEx distribution

The probability density function (PDF) for the NTLKwIEx distribution is given by the formula:

$f(x) = 2abm\dfrac{\theta}{x^{2}}\left( -\dfrac{\theta}{x}log\left( \alpha \right)+ exp\left( \dfrac{\theta}{x}\right)\right) \alpha^{exp\left(-\dfrac{\theta}{x}\right) }exp\left( -\dfrac{\theta}{x}\left(1+a\alpha^{exp\left(-\dfrac{\theta}{x}\right)}\right)\right) \left(1-exp\left( -a\dfrac{\theta}{x}\alpha^{exp\left(-\dfrac{\theta}{x}\right)} \right)\right)^{2b-1}\left( 1-\left( 1-exp\left( -\dfrac{a\theta}{x} \alpha^{exp\left(-\dfrac{\theta}{x}\right) }\right)\right)^{2b} \right)^{m-1}$ where $\left( \theta, \alpha , a , b, m\right) > 0$

### Example 1

Let’s calculate the PDF for $$x=1$$ , $$\theta=5$$, $$\alpha=4$$ , $$a=3$$ , $$b=2$$ and $$m=1$$

P_NTLKwIEx(x=1, teta=5, alpha=4, a=3, b=2, m=1)
#> [1] 1.534205e-05

### Example 2

Let’s calculate the PDF for $$x=20.5$$ , $$\theta=4$$, $$\alpha=0.04$$ , $$a=1.2$$ , $$b=1.3$$ and $$m=2.1$$

P_NTLKwIEx(x=20.5, teta=4, alpha=0.04, a=1.2, b=1.3, m=2.1)
#> [1] 9.19841e-06

## Cumulative density function (CDF) for NTLKwIEx distribution

The cumulative density function (CDF) for the NTLKwIEx distribution is given by the formula:

$F(x)=\left(1-\left( 1-exp\left( -\dfrac{a\theta}{x} \alpha^{exp\left(-\dfrac{\theta}{x}\right) }\right)\right)^{2b} \right)^{m}$ where $\left( \theta, \alpha , a , b, m\right) > 0$

### Example 1

Let’s calculate the CDF for $$x=1$$ , $$\theta=5$$, $$\alpha=4$$ , $$a=3$$ , $$b=2$$ and $$m=1$$

C_NTLKwIEx(x=1, teta=5, alpha=4, a=3, b=2, m=1)
#> [1] 1.062938e-06

### Example 2

Let’s calculate the CDF for $$x=20.5$$ , $$\theta=4$$, $$\alpha=0.04$$ , $$a=1.2$$ , $$b=1.3$$ and $$m=2.1$$

C_NTLKwIEx(x=20.5, teta=4, alpha=0.04, a=1.2, b=1.3, m=2.1)
#> [1] 0.9999518

## Graphical plot of the probability density function of NTLKwIEx distribution

This function generates a graphical plot of the probability density function (PDF) for the NTLKwIEx distribution.

### Example

Let’s plot the PDF for a range of values with parameters $$\theta=1.8$$, $$\alpha=1.6$$ , $$a=3$$ , $$b=1.3$$ and $$m=1.6$$ with $$min\_x=0$$ and $$max\_x=100$$


Plot_PNTLKwIEx(teta=1.8, alpha = 1.6, a=3, b=1.3, m=1.6, min_x = 0, max_x = 100)

## Graphical plot of the cumulative density function of NTLKwIEx distribution

This function generates a graphical plot of the cumulative density function (CDF) for the NTLKwIEx distribution.

### Example

Let’s plot the CDF for a range of values with parameters $$\theta=1.8$$, $$\alpha=1.6$$ , $$a=3$$ , $$b=1.3$$ and $$m=1.6$$ with $$min\_x=0$$ and $$max\_x=50$$

Plot_CNTLKwIEx(teta=1.8, alpha = 1.6, a=3, b=1.3, m=1.6, min_x = 0, max_x = 50)

## Quantile function for NTLKwIEx distribution

The quantile function calculates the quantile value for a given probability using the NTLKwIEx distribution.

### Example 1

Let’s calculate the quantile using parameters $$p=0.3$$ , $$\theta=1.8$$, $$\alpha=0.5$$ , $$a=5.4$$ , $$b=2.4$$ and $$m=8.2$$


Q_NTLKwIEx(p=0.3, teta = 1.8, alpha = 0.5, a=5.4, b=2.4, m=8.2)
#> [1] 5.465159

### Example 2

Let’s calculate the 0.5 quantile (median) using parameters $$p=0.5$$ , $$\theta=5.3$$, $$\alpha=3.2$$ , $$a=8.2$$ , $$b=1.8$$ and $$m=2.3$$


Q_NTLKwIEx(p=0.5, teta = 5.3, alpha = 3.2, a=8.2, b=1.8, m=2.3)
#> [1] 113.2177

## Generate random samples from the NTLKwIEx distribution

This function generates random samples from the NTLKwIEx distribution using the function sapply.

### Example 1

Let’s generate 100 random samples with parameters $$\theta=5.3$$, $$\alpha=3.2$$ , $$a=8.2$$ , $$b=1.8$$ and $$m=2.3$$

set.seed(100)
data=R_NTLKwIEx(100, teta = 5.3, alpha = 3.2, a=8.2, b=1.8, m=2.3)
data
#>   [1]  86.82640  80.53718 121.75249  51.41353 108.46004 110.73220 190.76535
#>   [8]  94.85908 120.76828  69.34952 135.36246 231.96326  83.37939  98.60411
#>  [15] 171.28838 145.00940  73.83060  93.18853  93.44205 150.18030 118.96422
#>  [22] 155.55415 119.38661 166.80422 101.55263  69.50365 173.98327 231.79593
#>  [29] 121.20020  83.04967 111.41997 281.34138  92.04493 330.66918 151.44860
#>  [36] 237.95324  70.69140 136.26983 543.33710  63.83008  89.73133 219.56888
#>  [43] 176.61393 197.80977 131.04323 111.86643 177.64258 233.61045  74.22785
#>  [50]  86.74053  89.71466  73.06791  77.77668  82.69410 128.75387  80.00035
#>  [57]  62.84032  77.04666 129.93809  74.69984 107.74751 140.04541 348.71764
#>  [64] 146.76042 105.06677  93.22087 106.58725 105.10470  78.95887 151.21186
#>  [71] 100.47143  89.35715 125.30829 370.94944 143.33098 135.30117 214.10252
#>  [78] 175.58877 201.23110  57.87579 107.13791 130.28675 269.35716 462.14739
#>  [85]  47.10868 126.27966 161.96784  79.41717  85.94000 162.01337 254.57297
#>  [92]  74.49665  93.26820 105.51713 254.01657  97.38995 115.97136  63.09704
#>  [99]  44.98030 174.51844

### Example 2

Let’s generate 150 random samples with parameters $$\theta=3.1$$, $$\alpha=0.2$$ , $$a=4.2$$ , $$b=2.8$$ and $$m=1.3$$

set.seed(100)
data=R_NTLKwIEx(150, teta = 3.1, alpha = 0.2, a=4.2, b=2.8, m=1.3)
data
#>   [1] 3.015766 2.891872 3.630332 2.238402 3.409102 3.447897 4.614222 3.167266
#>   [9] 3.614404 2.658206 3.843986 5.113648 2.948473 3.235615 4.358706 3.988596
#>  [17] 2.754000 3.136357 3.141071 4.064039 3.585028 4.141013 3.591927 4.297769
#>  [25] 3.288452 2.661550 4.394928 5.111716 3.621402 2.941960 3.459556 5.656023
#>  [33] 3.115000 6.152258 4.082335 5.182361 2.687227 3.857821 7.966051 2.535661
#>  [41] 3.071388 4.968544 4.430007 4.703286 3.777448 3.467127 4.443650 5.132632
#>  [49] 2.762357 3.014106 3.071071 2.737924 2.835907 2.934921 3.741751 2.881055
#>  [57] 2.513101 2.820909 3.760227 2.772239 3.396847 3.914815 6.324628 4.014299
#>  [65] 3.350379 3.136959 3.376791 3.351029 2.859991 4.078926 3.269168 3.064290
#>  [73] 3.687322 6.531100 3.963804 3.843050 4.903222 4.416370 4.745953 2.397150
#>  [81] 3.386316 3.765669 5.529126 7.321931 2.127055 3.702743 4.231079 2.869283
#>  [89] 2.998598 4.231712 5.368562 2.767986 3.137839 3.358208 5.362429 3.213637
#>  [97] 3.535757 2.518979 2.070163 4.402087 3.063541 3.213734 2.148818 3.145716
#> [105] 3.682792 4.044454 6.688133 4.107274 1.865733 3.584271 4.762542 4.582864
#> [113] 2.353932 2.844162 6.495891 2.126168 5.484980 4.202028 2.743630 4.786651
#> [121] 3.231142 3.221543 3.419269 3.719307 3.123930 2.056439 9.020607 6.240103
#> [129] 3.628471 2.437154 2.841607 4.929315 4.251764 3.482863 3.708471 1.931819
#> [137] 3.418184 2.157442 3.395468 3.859732 4.003269 2.379242 2.578127 5.386472
#> [145] 2.509914 4.212755 6.062540 2.163532 1.971913 2.738996

## Estimate parameters with constraints

This function estimates the parameters of the NTLKwIEx distribution while respecting constraints on the parameters.

### Example 1

Let’s estimate parameters from a sample data vector.

set.seed(100)
data=R_NTLKwIEx(100, teta = 5.3, alpha = 3.2, a=8.2, b=1.8, m=2.3)
E_NTLKwIEx(data)
#> [1] 261.6269738   6.0848513   1.6025754  27.4563884   0.9826208

### Example 2

Let’s estimate parameters from a sample data vector.

set.seed(100)
data=R_NTLKwIEx(150, teta = 3.1, alpha = 0.2, a=4.2, b=2.8, m=1.3)
E_NTLKwIEx(data)
#> [1]  2.268527  3.013980  1.377532  7.470795 20.477809

### Example 3

Let’s estimate parameters from a conductor failure times data.

E_NTLKwIEx(ConductorFailureTimes)
#> [1] 2.022804e+01 1.926479e-05 1.157130e+00 1.844454e+00 8.783435e-01

## Estimate parameters with constraints and plot histogram with estimated density

This function estimates parameters and plots the histogram of the data along with the estimated density curve.

### Example 1

set.seed(100)
data=R_NTLKwIEx(100, teta = 5.3, alpha = 3.2, a=8.2, b=1.8, m=2.3)
Sim_NTLKwIEx(data)

### Example 2

Sim_NTLKwIEx(ConductorFailureTimes)

This concludes the overview of the “NTLKwIEx” package and its functionalities for working with the New Topp-Leone Kumaraswamy Inverse Exponential distribution.