Package {rGrSPTT}


Type: Package
Title: Group Sampling Inspection Plan for Time Truncated Life Test
Version: 0.1.0
Description: Designing group acceptance sampling inspection plans under time-truncated life tests. The package calculates the required minimum number of groups subject to a consumer's risk constraint on the probability of acceptance. Users can supply failure probabilities obtained from any lifetime distribution, allowing the methodology to be applied without restricting the analysis to a particular probability model. The package also provides a function for plotting the required minimum number of groups against the termination ratio. Saha et al. (2025) <doi:10.1007/s41872-025-00305-w>; Tripathi et al. (2020) <doi:10.1080/02664763.2020.1759031>; Tripathi and Aslam (2024) <doi:10.1285/i20705948v17n3p636>.
License: GPL-3
Encoding: UTF-8
Config/roxygen2/version: 8.0.0
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2026-09-10 06:03:11 UTC; Admin
Author: Harsh Tripathi [aut, cre], Mahendra Saha [aut]
Maintainer: Harsh Tripathi <rsearchstat21@gmail.com>
Repository: CRAN
Date/Publication: 2026-09-17 14:40:28 UTC

Group Acceptance Sampling Inspection Plan

Description

Calculates the minimum required number of groups for a group acceptance sampling inspection plan under a time-truncated life test.

Usage

group_asip(p, a, b, r, be = 0.25, c = 0)

Arguments

p

User-defined probability of failure before the termination time. It must lie between 0 and 1.

a

Termination ratio, defined as a = t/theta0. It must be a positive numeric value.

b

Quality ratio, defined as b = theta/theta0. It must be a positive numeric value.

r

Number of items inspected in each group. It must be a positive integer.

be

Producer's risk. It must be a value between 0 and 1.

c

Acceptance number, representing the maximum number of failures allowed in each group. It must be a non-negative integer.

Details

The probability of failure before the termination time is supplied by the user through the argument 'p'. Therefore, the function is distribution-free and can be used with different lifetime distributions.

Each group consists of 'r' items. A group is accepted if it contains at most 'c' failures before the termination time.

If the probability of failure for an individual item is 'p', the probability that a group contains at most 'c' failures is

P_g = \sum_{i=0}^{c} {r \choose i} p^i(1-p)^{r-i}

which is equivalent to

P_g = P(X \leq c)

where X follows a Binomial distribution with parameters 'r' and 'p'.

If 'g' groups are inspected, the probability of acceptance is

P_a = (P_g)^g

The function determines the minimum number of groups 'g' satisfying the producer's risk condition

P_a \leq be

The total number of inspected items is

n = g r.

The lifetime distribution is not embedded in the function. The user calculates the probability 'p' from the required lifetime distribution and supplies it to the function.

Value

A data frame containing 'a', 'b', 'p', 'r', 'be', 'c', the probability of accepting a group 'pg', the required number of groups 'g', the total sample size 'n', and the probability of acceptance 'Pa'.

Examples


# ----------------------------------------------------------
# Example 1: User-defined failure probabilities
# ----------------------------------------------------------

p <- c(0.05, 0.10, 0.15, 0.20)

group_asip(
  p = p,
  a = c(0.5, 1, 1.5, 2),
  b = 1,
  r = 5,
  be = 0.25,
  c = 0
)


# ----------------------------------------------------------
# Example 2: Weibull distribution
# ----------------------------------------------------------

# For a Weibull distribution,
#
# F(t) = 1 - exp[-(t/theta)^beta]
#
# Using a = t/theta0 and b = theta/theta0,
#
# p = 1 - exp[-(a/b)^beta].

beta <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- 1 - exp(
  -((a / b)^beta)
)

group_asip(
  p = p,
  a = a,
  b = b,
  r = 5,
  be = 0.25,
  c = 0
)



Operating Characteristic Values for a Group Acceptance Sampling Plan

Description

Calculates the probability of acceptance for different quality ratios using the number of groups obtained from a group acceptance sampling plan designed at b = 1.

Usage

group_oc(p_design, a, p_oc, b_oc, r, be = 0.25, c = 0)

Arguments

p_design

Probability of failure used to determine the sampling plan at b = 1.

a

Termination ratio corresponding to each value of 'p_design'.

p_oc

Matrix of failure probabilities for different quality ratios. Each row corresponds to a value of 'a', and each column corresponds to a value of 'b_oc'.

b_oc

Numeric vector of quality ratios corresponding to the columns of 'p_oc'.

r

Number of items inspected in each group.

be

Producer's risk.

c

Acceptance number.

Value

A data frame containing the termination ratio, quality ratio, failure probability, required number of groups, total sample size, and probability of acceptance.

Examples


beta <- 2

a <- c(0.5, 1, 1.5, 2)

# Failure probabilities at b = 1
p_design <- 1 - exp(-(a / 1)^beta)

# Quality ratios for OC calculation
b_oc <- 2:12

# Failure probabilities for each a and b
p_oc <- sapply(
  b_oc,
  function(b)
    1 - exp(-((a / b)^beta))
)

# The output contains:
# pg = probability of accepting a single group
# Pa = probability of accepting the complete sampling plan.
# The Pa values represent the OC values for the specified
# quality ratios (b = 2, 3, ..., 12).
group_oc(
  p_design = p_design,
  a = a,
  p_oc = p_oc,
  b_oc = b_oc,
  r = 5,
  be = 0.25,
  c = 0
)


Plot Total Sample Size Against Termination Ratio

Description

Calculates the minimum required number of groups and total sample size for different termination ratios, and aslo plots the required minimum number of groups against the termination ratio.

Usage

plot_group_asip(p, a, b = 1, r, be = 0.25, c = 0, ylim = NULL)

Arguments

p

User-defined probability of failure corresponding to each termination ratio.

a

Numeric vector of termination ratios.

b

Quality ratio. It may be a single value or a vector having the same length as 'a'.

r

Number of items inspected in each group.

be

Producer's risk.

c

Acceptance number.

ylim

Numeric vector of length two specifying the limits of the y-axis. Default is 'NULL'.

Details

The user supplies the corresponding values of 'p' calculated from any lifetime distribution.

Value

A data frame containing 'a', 'b', 'p', 'r', 'g' and the total sample size 'n'.

Examples

#---------------------------------------------------------
# Example 1: User-defined failure probabilities
#---------------------------------------------------------

p <- c(0.05, 0.10, 0.15, 0.20)

plot_group_asip(
  p = p,
  a = c(0.5, 1, 1.5, 2),
  b = 1,
  r = 5,
  be = 0.25,
  c = 0,
  ylim=c(0,1000)
)


# Weibull example

beta <- 2
b <- 1

a <- c(
  0.5, 0.75, 1, 1.25,
  1.5, 1.75, 2
)

p <- 1 - exp(
  -((a / b)^beta)
)

plot_group_asip(
  p = p,
  a = a,
  b = b,
  r = 5,
  be = 0.25,
  c = 0,
  ylim=c(0,1000)
)