Skip to content

Commit

Permalink
version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmazarei authored and cran-robot committed Aug 25, 2023
0 parents commit 36605cd
Show file tree
Hide file tree
Showing 38 changed files with 3,197 additions and 0 deletions.
28 changes: 28 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Package: ntsDists
Type: Package
Title: Neutrosophic Distributions
Version: 1.0.0
Authors@R: c(
person("Danial", "Mazarei", email = "danial.mazarei@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3633-9298")),
person("Foad", "Esmaeili", email = "foadesmaeili5@gmail.com", role = "aut", comment = c(ORCID = "0000-0002-9638-0807")),
person("Mina", "Norouzirad", email = "mina.norouzirad@gmail.com", role = "aut", comment = c(ORCID = "0000-0003-0311-6888")),
person("Gadde Srinivasa", "Rao", email = "gaddesrao@gmail.com", role = "ctb", comment = c(ORCID = "0000-0002-3683-5486")),
person("FCT, I.P.", role = "fnd", comment = c("under the scope of the projects UIDB/00297/2020 and UIDP/00297/2020 (NovaMath)")))
Maintainer: Danial Mazarei <danial.mazarei@gmail.com>
Description: Computes the pdf, cdf, quantile function and generating random numbers for neutrosophic distributions. This family have been developed by different authors in the recent years. See Patro and Smarandache (2016) <doi:10.5281/zenodo.571153> and Rao et al (2023) <doi:10.5281/zenodo.7832786>.
License: GPL (>= 2)
URL: https://github.com/dmazarei/ntsDists
Encoding: UTF-8
LazyData: false
RoxygenNote: 7.2.3
Depends: R (>= 3.5)
NeedsCompilation: no
Packaged: 2023-08-24 15:36:26 UTC; dmeza
Author: Danial Mazarei [aut, cre] (<https://orcid.org/0000-0002-3633-9298>),
Foad Esmaeili [aut] (<https://orcid.org/0000-0002-9638-0807>),
Mina Norouzirad [aut] (<https://orcid.org/0000-0003-0311-6888>),
Gadde Srinivasa Rao [ctb] (<https://orcid.org/0000-0002-3683-5486>),
FCT, I.P. [fnd] (under the scope of the projects UIDB/00297/2020 and
UIDP/00297/2020 (NovaMath))
Repository: CRAN
Date/Publication: 2023-08-25 08:00:05 UTC
37 changes: 37 additions & 0 deletions MD5
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
5b0cf0a7354243d01747af4d3fe53212 *DESCRIPTION
af883516d1787126a84fbf7a53c0e637 *NAMESPACE
3b908ad6b81a4af8d59c08112127ae05 *NEWS.md
1ebc0461d515bea8ca4e3113440a9858 *R/balls.R
15381166f9ed81ee96e7a3b1728bd92b *R/nsbeta.R
2cab43abe7da50fd9b40d6589fbfc93b *R/nsbinom.R
1e777f55d543c7840839f81ee3830ff8 *R/nsdunif.R
d260445b3f786195d4923b5e23549ccd *R/nsexp.R
4476f787b7dbd9e161b7a731bd6faa4e *R/nsgamma.R
8a7c8d7f310fcf4f47fe77060922e5fe *R/nsgeom.R
4d73aad2b8468966df28adefb009aae6 *R/nsgexp.R
64937ecaa21f8d0dfbbd0d3d8ed49b69 *R/nsnbinom.R
f9efc08d00d9ae10395eea42b8ec5007 *R/nsnorm.R
2fd93f598c2699ef6f3739c055d02323 *R/nspois.R
45e51e80a98ac76cab90fd6dd858719a *R/nsrayleigh.R
2ebd571d290158b95228d31c52cef7b5 *R/nsunif.R
ce4fd9e280ca50cd2bf882ef3ad658cc *R/nsweibull.R
90ff9467cb7be23ad6fb88d0aa3e1e40 *R/remission.R
5ab462d5c8f2bf3e0c79e0369d2f6c21 *README.md
ce65505c6eb8aa8cfcc32bf85b5ae9ef *data/balls.rda
86c589b7ea74433b2c9658496e1e4afe *data/remission.rda
a30d110b5385984eb0ae8727298a37da *man/Neutrosophic-Beta.Rd
10ab34eb7ff0b6294508dc96dd5d1c2d *man/Neutrosophic-Binomial.Rd
60414ede69808a9654e5d048c274e901 *man/Neutrosophic-Discrete-Uniform.Rd
93638dd88af5224a922bc40593666c96 *man/Neutrosophic-Exponential.Rd
2d13d13434b498fab2d52169ec3f28ec *man/Neutrosophic-Gamma.Rd
a29ca010241febd7534c3addb0574a33 *man/Neutrosophic-Generalized-Exponential.Rd
44e3c2e7b28946708becc8aa5e29dd5b *man/Neutrosophic-Geometric.Rd
82364ac525912dbb4fbb3468ea2adef9 *man/Neutrosophic-Negative-Binomial.Rd
343c8819b5b4de780f83da7f46d94b0b *man/Neutrosophic-Normal.Rd
a9027a873738df7d81d99ff0e7ff4558 *man/Neutrosophic-Poisson.Rd
8ac7f68646534b6f023c7ba121e304fd *man/Neutrosophic-Rayleigh.Rd
7beb4388178bd74c4521fe7581b091ed *man/Neutrosophic-Uniform.Rd
5debf386c113e6b4c2184b0e7337fbee *man/Neutrosophic-Weibull.Rd
6f4958b916fc94eb5a8a03ec44e07e9e *man/balls.Rd
5c51b6a3ce788961768acc610cccb980 *man/figures/logo.png
c68ea3f44e13db02547296ef85143b41 *man/remission.Rd
82 changes: 82 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Generated by roxygen2: do not edit by hand

export(dnsbeta)
export(dnsbinom)
export(dnsdunif)
export(dnsexp)
export(dnsgamma)
export(dnsgeom)
export(dnsgexp)
export(dnsnbinom)
export(dnsnorm)
export(dnspois)
export(dnsrayleigh)
export(dnsunif)
export(dnsweibull)
export(pnsbeta)
export(pnsbinom)
export(pnsdunif)
export(pnsexp)
export(pnsgamma)
export(pnsgeom)
export(pnsgexp)
export(pnsnbinom)
export(pnsnorm)
export(pnspois)
export(pnsrayleigh)
export(pnsunif)
export(pnsweibull)
export(qnsbeta)
export(qnsbinom)
export(qnsdunif)
export(qnsexp)
export(qnsgamma)
export(qnsgeom)
export(qnsgexp)
export(qnsnbinom)
export(qnsnorm)
export(qnspois)
export(qnsrayleigh)
export(qnsunif)
export(qnsweibull)
export(rnsbeta)
export(rnsbinom)
export(rnsdunif)
export(rnsexp)
export(rnsgamma)
export(rnsgeom)
export(rnsgexp)
export(rnsnbinom)
export(rnsnorm)
export(rnspois)
export(rnsrayleigh)
export(rnsunif)
export(rnsweibull)
importFrom(stats,dbeta)
importFrom(stats,dbinom)
importFrom(stats,dgamma)
importFrom(stats,dgeom)
importFrom(stats,dnbinom)
importFrom(stats,dnorm)
importFrom(stats,dpois)
importFrom(stats,dunif)
importFrom(stats,dweibull)
importFrom(stats,pbeta)
importFrom(stats,pbinom)
importFrom(stats,pgamma)
importFrom(stats,pgeom)
importFrom(stats,pnbinom)
importFrom(stats,pnorm)
importFrom(stats,ppois)
importFrom(stats,punif)
importFrom(stats,pweibull)
importFrom(stats,qbeta)
importFrom(stats,qbinom)
importFrom(stats,qgamma)
importFrom(stats,qgeom)
importFrom(stats,qnbinom)
importFrom(stats,qnorm)
importFrom(stats,qpois)
importFrom(stats,qunif)
importFrom(stats,qweibull)
importFrom(stats,runif)
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ntsDists 1.0.0

* Initial CRAN submission.
24 changes: 24 additions & 0 deletions R/balls.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#' Balls data
#'
#' It is related to failure times of 23 bearing balls.
#'
#'
#' @name balls
#'
#' @format
#' A data.frame with 23 observations of failure times of bearing balls.
#'
#' @source
#' Lawless, J. F. (2003). Statistical Models and Methods for Lifetime Data, Wiley,
#' Hoboken, NJ, USA.
#'
#' Salam, S., Khan, Z., Ayed, H., Brahmia, A., Amin, A. (2021).
#' The Neutrosophic Lognormal Model in Lifetime Data Analysis: Properties and
#' Applications, \emph{Fuzzy Sets and Their Applications in Mathematics},
#' Article ID 6337759.
#'
#' @examples
#' data("balls")
#' balls
NULL

154 changes: 154 additions & 0 deletions R/nsbeta.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#' Neutrosophic Beta Distribution
#'
#' Density, distribution function, quantile function and random
#' generation for the nuetrosophic Beta distribution with shape parameters
#' \code{shape1} = \eqn{\alpha_N} and \code{shape2} = \eqn{\beta_N}.
#'
#' The neutrosophic beta distribution with parameters \eqn{\alpha_N} and
#' \eqn{\beta_N} has the probability density function
#' \deqn{f_N(X) = \frac{1}{B(\alpha_N, \beta_N)} X^{\alpha_N - 1} (1 - X)^{\beta_N - 1}}
#' for \eqn{\alpha_N \in (\alpha_L, \alpha_U)}, the first shape parameter which
#' must be a positive interval, and \eqn{\beta_N \in (\beta_L, \beta_U)},
#' the second shape parameter which must also be a positive interval, and
#' \eqn{0 \le x \le 1}. The function \eqn{B(a, b)}
#' returns the beta function and can be calculated using \code{\link{beta}}.
#'
#' @name Neutrosophic Beta
#'
#' @param x a vector or matrix of observations for which the pdf needs to be computed.
#' @param q a vector or matrix of quantiles for which the cdf needs to be computed.
#' @param p a vector or matrix of probabilities for which the quantile needs to be computed.
#' @param n number of random values to be generated.
#' @param shape1 the first shape parameter, which must be a positive interval.
#' @param shape2 the second shape parameter, which must be a positive interval.
#' @param lower.tail logical; if TRUE (default), probabilities are
#' \eqn{P(X \ge x)}; otherwise, \eqn{P(X >x)}.
#'
#' @return
#' \code{pnsbeta} gives the distribution function,
#' \code{dnsbeta} gives the density,
#' \code{qnsbeta} gives the quantile function and
#' \code{rnsbeta} generates random values from the neutrosophic Beta distribution.
#'
#' @references
#' Sherwani, R. Ah. K., Naeem, M., Aslam, M., Reza, M. A., Abid, M., Abbas, S. (2021).
#' Neutrosophic beta distribution with properties and applications.
#' \emph{Neutrosophic Sets and Systems}, 41, 209-214.
#' @importFrom stats runif dbeta pbeta qbeta
#' @examples
#'
#' dnsbeta(x = c(0.1, 0.2), shape1 = c(1, 1), shape2 = c(2, 2))
#' dnsbeta(x = 0.1, shape1 = c(1, 1), shape2 = c(2, 2))
#'
#' x <- matrix(c(0.1, 0.1, 0.2, 0.3, 0.5, 0.5), ncol = 2, byrow = TRUE)
#' dnsbeta(x, shape1 = c(1, 2), shape2 = c(2, 3))
#'
#' @export
dnsbeta <- function(x, shape1, shape2) {
if (any(shape1 <= 0) || any(shape2 <= 0) || any(x < 0)) {
stop(message = "Arguments are incompatible.")
}

shape1 <- rep(shape1, length.out = 2)
shape2 <- rep(shape2, length.out = 2)


if (is.vector(x) || ncol(x) == 1) {
x <- matrix(rep(as.numeric(x), each = 2), ncol = 2, byrow = TRUE)
}

if (ncol(x) > 2) {
stop(message = "Arguments are incompatible.")
}


pdf <- matrix(NA, nrow = nrow(x), ncol = 2)
for (i in 1:2) {
pdf[, i] <- stats::dbeta(x[, i], shape1 = shape1[i], shape2 = shape2[i])
}

return(pdf)
}
#' @name Neutrosophic Beta
#' @examples
#'
#' pnsbeta(q = c(0.1, 0.1), shape1 = c(3, 1), shape2 = c(1, 3), lower.tail = FALSE)
#' pnsbeta(x, shape1 = c(1, 2), shape2 = c(2, 2))
#'
#' @export
pnsbeta <- function(q, shape1, shape2, lower.tail = TRUE) {
if (any(shape1 <= 0) || any(shape2 <= 0) || any(q < 0)) {
stop("Arguments are incompatible.")
}

shape1 <- rep(shape1, length.out = 2)
shape2 <- rep(shape2, length.out = 2)
if (is.vector(q) || ncol(q) == 1) {
q <- matrix(rep(as.numeric(q), each = 2), ncol = 2, byrow = TRUE)
}
if (ncol(q) > 2) {
stop(message = "Arguments are incompatible.")
}

cdf <- matrix(NA, nrow = nrow(q), ncol = 2)
for (i in 1:2) {
cdf[, i] <- stats::pbeta(q[, i], shape1 = shape1[i], shape2 = shape2[i])
}

if (!lower.tail) {
cdf <- 1 - cdf
}


return(cdf)
}
#' @name Neutrosophic Beta
#' @examples
#'
#' qnsbeta(p = 0.1, shape1 = c(1, 1), shape2 = c(2, 2))
#' qnsbeta(p = c(0.25, 0.5, 0.75), shape1 = c(1, 2), shape2 = c(2, 2))
#'
#' @export
qnsbeta <- function(p, shape1, shape2) {
if (any(p < 0) || any(p > 1)) {
stop(message = "Warning: p should be in the interval [0,1].")
}

if (any(shape1 <= 0) || any(shape2 <= 0)) {
stop(message = "Arguments are incompatible.")
}

shape1 <- rep(shape1, length.out = 2)
shape2 <- rep(shape2, length.out = 2)

if (is.vector(p) || ncol(p) == 1) {
p <- matrix(rep(as.numeric(p), each = 2), ncol = 2, byrow = TRUE)
}
if (ncol(p) > 2) {
stop(message = "Arguments are incompatible.")
}
quantiles <- matrix(NA, nrow = nrow(p), ncol = 2)
for (i in 1:2) {
quantiles[, i] <- stats::qbeta(p[, i], shape1 = shape1[i], shape2 = shape2[i])
}

return(quantiles)
}
#' @name Neutrosophic Beta
#' @examples
#' # Simulate 10 numbers
#' rnsbeta(n = 10, shape1 = c(1, 2), shape2 = c(1, 1))
#' @export
rnsbeta <- function(n, shape1, shape2) {
if (any(shape1 <= 0) || any(shape2 <= 0)) {
stop(message = "Arguments are incompatible.")
}
shape1 <- rep(shape1, length.out = 2)
shape2 <- rep(shape2, length.out = 2)

X <- qnsbeta(runif(n), shape1, shape2)
condition <- X[, 1] > X[, 2]
X[condition, 1:2] <- X[condition, 2:1]

return(X)
}

0 comments on commit 36605cd

Please sign in to comment.