Compute
accumulate_values(sequence)
Computes the cumulative sum of a sequence of numbers.
Parameters: sequence (iterable): A sequence (e.g., list, tuple) of numerical values to be accumulated.
Returns: list: A list containing the accumulated sums. Each element corresponds to the sum of the values in the sequence up to that index.
Example:
accumulate_values([1, 2, 3, 4]) [1, 3, 6, 10]
Source code in wgrp/compute.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
bootstrap_sample(parameters)
Generates random time series of failures using the wgrp model parameters.
This function uses the parameters alpha, beta, and q from the wgrp model to simulate failure series.
For each sample, the qwgrp function is called to calculate the failure times, which are stored in a sample matrix.
Parameters (dict): Dictionary containing the following parameters required for series generation: nSamples (int): number of samples to be generated. nInterventions (int): number of interventions in each sample. a (float): value of the alpha parameter for the wgrp model. b (float): value of the beta parameter for the wgrp model. q (float): value of the q parameter for the wgrp model. propagations (int) or (list): number of propagations to be performed. previousVirtualAge (int): initial previous virtual age of accumulated failures. cumulativeFailureCount (int): cumulative count of failures. timesPredictFailures (float): prediction time for future failures.
Returns(dict): Dictionary with the following keys: sample_matrix: matrix (numpy array) with failure times for each sample, where each row represents a sample and each column represents an intervention. events_in_the_future_tense: list of mean times for predicted failures.
Example:
parameters = {
'nSamples': 100,
'nInterventions': 10,
'a': 0.5,
'b': 1.5,
'q': 0.2,
'propagations': 5,
'previousVirtualAge': 10,
'cumulativeFailureCount': 0,
'timesPredictFailures': 20
}
result = bootstrap_sample(parameters)
References: - Ferreira RJ, Firmino PRA, Cristino CT (2015): A Mixed Kijima Model Using the Weibull-Based Generalized Renewal Processes. PLoS ONE, 10(7), e0133772. https://doi.org/10.1371/journal.pone.0133772
Source code in wgrp/compute.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |