Skip to content

Demonstration test planning

demonstration_sample_size

demonstration_sample_size(reliability, confidence=0.95, failures=0, *, test_multiple=1.0, shape=None)

The fewest units whose test demonstrates a reliability.

The smallest n for which n units tested, with at most failures of them failing, demonstrate reliability over a mission at confidence: the chance that so few fail, were the reliability only the target, is at most 1 - confidence. With no failures this is the success run, n = ln(1 - confidence) / ln(reliability) rounded up, the inverse of surpyval's success_run. Testing each unit for test_multiple missions, with the lifetime's Weibull shape known, needs fewer units (the extended success run, or Weibayes).

Parameters:

Name Type Description Default
reliability float

The reliability to demonstrate over one mission, in (0, 1).

required
confidence float

The confidence level, in (0, 1), by default 0.95.

0.95
failures int

The failures the test allows, by default 0.

0
test_multiple float

How many missions long each unit's test is, by default 1.0.

1.0
shape float

The Weibull shape of the lifetime, needed when test_multiple is not 1.

None

Returns:

Type Description
int

The number of units to test.

Raises:

Type Description
ValueError

If an argument is out of range, or test_multiple is not 1 and no shape is given.

Examples:

59 units with no failures demonstrate 95% reliability at 95% confidence, and allowing one failure takes 93:

>>> from repyability import demonstration_sample_size
>>> demonstration_sample_size(0.95, 0.95)
59
>>> demonstration_sample_size(0.95, 0.95, failures=1)
93

Testing each unit for two missions, for a wear-out shape of 2, needs a quarter of the units:

>>> demonstration_sample_size(0.95, 0.95, test_multiple=2.0, shape=2.0)
15

demonstrated_reliability

demonstrated_reliability(n, confidence=0.95, failures=0, *, test_multiple=1.0, shape=None)

The reliability a finished test demonstrated.

The lower one-sided confidence bound on the reliability over a mission, from n units tested with failures of them failing: the Clopper-Pearson bound, the smallest reliability for which so few failures have a chance of at least 1 - confidence. With no failures it is (1 - confidence) ** (1 / n), surpyval's success_run. A test of test_multiple missions per unit, with the lifetime's Weibull shape known, demonstrates that bound to the power 1 / test_multiple ** shape over one mission.

Parameters:

Name Type Description Default
n int

The number of units tested, at least 1.

required
confidence float

The confidence level, in (0, 1), by default 0.95.

0.95
failures int

How many of them failed, from 0 to n, by default 0.

0
test_multiple float

How many missions long each unit's test was, by default 1.0.

1.0
shape float

The Weibull shape of the lifetime, needed when test_multiple is not 1.

None

Returns:

Type Description
float

The demonstrated reliability over one mission.

Raises:

Type Description
ValueError

If an argument is out of range, or test_multiple is not 1 and no shape is given.

Examples:

>>> from repyability import demonstrated_reliability
>>> round(demonstrated_reliability(59), 4)
0.9505
>>> round(demonstrated_reliability(93, failures=1), 5)
0.95001

demonstration_test_multiple

demonstration_test_multiple(reliability, n, confidence=0.95, failures=0, *, shape)

How many missions long each unit's test must be to demonstrate a reliability with n units.

The shortest test, as a multiple of the mission time, for which n units with at most failures failing demonstrate reliability at confidence, the lifetime's Weibull shape known (the extended success run, or Weibayes). Below 1, a test shorter than a mission is enough.

Parameters:

Name Type Description Default
reliability float

The reliability to demonstrate over one mission, in (0, 1).

required
n int

The number of units to test, more than failures.

required
confidence float

The confidence level, in (0, 1), by default 0.95.

0.95
failures int

The failures the test allows, by default 0.

0
shape float

The Weibull shape of the lifetime.

required

Returns:

Type Description
float

The test length, in missions.

Raises:

Type Description
ValueError

If an argument is out of range.

Examples:

Twenty units, for a wear-out shape of 2, each run about 1.7 missions to demonstrate 95% reliability at 95% confidence (with a test of one mission, 59 units would be needed):

>>> from repyability import demonstration_test_multiple
>>> round(demonstration_test_multiple(0.95, 20, shape=2.0), 3)
1.709

demonstration_pass_probability

demonstration_pass_probability(reliability, n, failures=0, *, test_multiple=1.0, shape=None)

The chance that a design of a given true reliability passes a test.

The probability that at most failures of n units fail when each survives a mission with probability reliability (the test's operating characteristic). At the target reliability it is at most 1 - confidence for a planned test, the consumer's risk; one minus it at a good design's reliability is the producer's risk, the chance of failing a design that should pass.

Parameters:

Name Type Description Default
reliability float

The design's true reliability over one mission, in (0, 1).

required
n int

The number of units tested, at least 1.

required
failures int

The failures the test allows, by default 0.

0
test_multiple float

How many missions long each unit's test is, by default 1.0.

1.0
shape float

The Weibull shape of the lifetime, needed when test_multiple is not 1.

None

Returns:

Type Description
float

The probability of passing.

Raises:

Type Description
ValueError

If an argument is out of range, or test_multiple is not 1 and no shape is given.

Examples:

The 59-unit, no-failure test passes a design at the 95% target about one time in twenty, and one of 99% reliability five times in nine:

>>> from repyability import demonstration_pass_probability
>>> round(demonstration_pass_probability(0.95, 59), 3)
0.048
>>> round(demonstration_pass_probability(0.99, 59), 3)
0.553

demonstration_plan

demonstration_plan(reliability, good_reliability, confidence=0.95, producer_risk=0.2, *, n=None, test_multiple=1.0, shape=None, max_failures=1000)

The smallest attribute test that demonstrates a reliability and that a good design passes.

A plan's consumer's risk is the chance that a design of the target reliability passes it, at most 1 - confidence; its producer's risk is the chance that a design of good_reliability, which should pass, fails it, at most producer_risk. A test allowing no failures keeps the first with the fewest units, but often fails a good design: allowing failures, with more units, keeps both. For each number of failures allowed, from none, the fewest units that keep the consumer's risk (demonstration_sample_size) pass the good design most often, and the first of those plans that keeps the producer's risk tests the fewest units of all.

Given n, the test length is searched instead, with the lifetime's Weibull shape: the shortest test of n units that keeps both risks (each failure allowed takes a longer test, as demonstration_test_multiple gives it).

Parameters:

Name Type Description Default
reliability float

The reliability to demonstrate over one mission, in (0, 1).

required
good_reliability float

The reliability of a design that should pass, more than reliability and less than 1.

required
confidence float

The confidence level, in (0, 1), by default 0.95: the consumer's risk is at most 1 - confidence.

0.95
producer_risk float

The most chance of failing a good design, in (0, 1), by default 0.2.

0.2
n int

The number of units to test, to search the test length instead of the number of units (with shape).

None
test_multiple float

Without n: how many missions long each unit's test is, by default 1.0 (another length needs shape).

1.0
shape float

The Weibull shape of the lifetime, needed for a test longer or shorter than a mission, and with n.

None
max_failures int

The most failures a plan may allow, by default 1000.

1000

Returns:

Type Description
DemonstrationPlan

The plan: n, test_multiple and failures, and its risks.

Raises:

Type Description
ValueError

If an argument is out of range, good_reliability is no more than reliability, n is given without shape, or no plan within max_failures (or, given n, fewer failures than units) keeps both risks.

Examples:

Demonstrating 90% reliability at 90% confidence, so that a design of 95% passes at least 80% of the time: a test of 22 units with no failures would pass that design only a third of the time, and the plan tests 128, allowing 8 to fail:

>>> from repyability import demonstration_plan
>>> from repyability import demonstration_pass_probability
>>> round(demonstration_pass_probability(0.95, 22), 2)
0.32
>>> plan = demonstration_plan(0.9, 0.95, confidence=0.9)
>>> plan.n, plan.failures
(128, 8)
>>> round(plan.consumer_risk, 3), round(plan.producer_risk, 3)
(0.097, 0.192)

mtbf_test_time

mtbf_test_time(mtbf, confidence=0.95, failures=0, *, failure_terminated=False)

The total test time that demonstrates an MTBF, at a constant failure rate.

The unit time (summed over the units, failed ones repaired or replaced) a time-terminated test needs, with at most failures failures, to demonstrate mtbf at confidence: mtbf * chi2.ppf(confidence, 2 * failures + 2) / 2. A failure-terminated test, which runs until its failures-th failure, demonstrates mtbf if that failure comes after mtbf * chi2.ppf(confidence, 2 * failures) / 2: the time of a time-terminated test that allows one failure fewer.

Parameters:

Name Type Description Default
mtbf float

The mean time between failures to demonstrate, positive.

required
confidence float

The confidence level, in (0, 1), by default 0.95.

0.95
failures int

The failures the test allows, by default 0; with failure_terminated, the failure it stops at, from 1.

0
failure_terminated bool

Whether the test stops at its failures-th failure rather than at a time, by default False.

False

Returns:

Type Description
float

The total test time, in the MTBF's units.

Raises:

Type Description
ValueError

If an argument is out of range.

Examples:

With no failures, about 3 MTBFs of testing demonstrate the MTBF at 95% confidence:

>>> from repyability import mtbf_test_time
>>> round(mtbf_test_time(1000.0), 1)
2995.7
>>> round(mtbf_test_time(1000.0, failures=2), 1)
6295.8
>>> round(mtbf_test_time(1000.0, failures=3, failure_terminated=True), 1)
6295.8

demonstrated_mtbf

demonstrated_mtbf(test_time, confidence=0.95, failures=0, *, failure_terminated=False)

The MTBF a finished test demonstrated, at a constant failure rate.

The lower one-sided confidence bound on the MTBF from a total test time with failures failures. A test stopped at its time (time-terminated) gives 2 * test_time / chi2.ppf(confidence, 2 * failures + 2); one stopped at its failures-th failure (failure_terminated), with 2 * failures degrees of freedom instead.

Parameters:

Name Type Description Default
test_time float

The total unit time tested, positive: with failure_terminated, up to the last failure.

required
confidence float

The confidence level, in (0, 1), by default 0.95.

0.95
failures int

The failures seen, by default 0 (at least 1 with failure_terminated).

0
failure_terminated bool

Whether the test stopped at its last failure rather than at a time, by default False.

False

Returns:

Type Description
float

The demonstrated MTBF, in the test time's units.

Raises:

Type Description
ValueError

If an argument is out of range.

Examples:

>>> from repyability import demonstrated_mtbf
>>> round(demonstrated_mtbf(2995.7), 1)
1000.0

Three failures, the test stopped at the third, 6,295.8 hours in all:

>>> mtbf = demonstrated_mtbf(6295.8, failures=3, failure_terminated=True)
>>> round(mtbf, 1)
1000.0

mtbf_pass_probability

mtbf_pass_probability(mtbf, test_time, failures=0, *, failure_terminated=False)

The chance that a design of a given true MTBF passes a test, at a constant failure rate.

The probability of at most failures failures in test_time when failures come at rate 1 / mtbf: the Poisson distribution's, the test's operating characteristic. A failure-terminated test passes if its failures-th failure comes after test_time: at most one fewer by then.

Parameters:

Name Type Description Default
mtbf float

The design's true mean time between failures, positive.

required
test_time float

The total unit time tested, positive: with failure_terminated, the time the last failure must come after.

required
failures int

The failures the test allows, by default 0; with failure_terminated, the failure it stops at, from 1.

0
failure_terminated bool

Whether the test stops at its failures-th failure, by default False.

False

Returns:

Type Description
float

The probability of passing.

Raises:

Type Description
ValueError

If an argument is out of range.

Examples:

A test planned to demonstrate an MTBF of 1000 passes a design at that MTBF one time in twenty, and one with three times the MTBF only a little more than one time in three:

>>> from repyability import mtbf_pass_probability, mtbf_test_time
>>> time = mtbf_test_time(1000.0)
>>> round(mtbf_pass_probability(1000.0, time), 3)
0.05
>>> round(mtbf_pass_probability(3000.0, time), 3)
0.368

mtbf_demonstration_plan

mtbf_demonstration_plan(mtbf, good_mtbf, confidence=0.95, producer_risk=0.2, *, max_failures=1000)

The shortest constant-failure-rate test that demonstrates an MTBF and that a good design passes.

The total test time and the failures it allows, for a time-terminated test, such that a design of the target mtbf passes with a chance of at most 1 - confidence (the consumer's risk) and one of good_mtbf fails with a chance of at most producer_risk: the fixed-length test plans of MIL-HDBK-781, for a discrimination ratio good_mtbf / mtbf. For each number of failures allowed, from none, the shortest test that keeps the consumer's risk (mtbf_test_time) passes the good design most often, and the first that keeps the producer's risk is the shortest of all. Both risks are kept, where some of the handbook's plans exceed one a little for a shorter test; those that keep both are these (plans XI-D, XV-D and XVII-D).

Parameters:

Name Type Description Default
mtbf float

The MTBF to demonstrate, positive.

required
good_mtbf float

The MTBF of a design that should pass, more than mtbf.

required
confidence float

The confidence level, in (0, 1), by default 0.95.

0.95
producer_risk float

The most chance of failing a good design, in (0, 1), by default 0.2.

0.2
max_failures int

The most failures a plan may allow, by default 1000.

1000

Returns:

Type Description
DemonstrationPlan

The plan: test_time and failures, and its risks.

Raises:

Type Description
ValueError

If an argument is out of range, good_mtbf is no more than mtbf, or no plan within max_failures keeps both risks.

Examples:

Demonstrating an MTBF of 1000 hours at 90% confidence, so that a design of 2000 passes at least 80% of the time (a discrimination ratio of 2): the test runs about 14,200 unit hours, and passes with at most 9 failures:

>>> from repyability import mtbf_demonstration_plan
>>> plan = mtbf_demonstration_plan(1000.0, 2000.0, confidence=0.9)
>>> round(plan.test_time), plan.failures
(14206, 9)
>>> round(plan.consumer_risk, 3), round(plan.producer_risk, 3)
(0.1, 0.18)