Probabilistic

Monte Carlo weights simulation

pysensmcda.probabilistic.monte_carlo_weights.monte_carlo_weights(n: int, distribution: str = 'uniform', num_samples: int = 1000, params: dict = {}) ndarray[source]

Generate criteria weights probabilistically using Monte Carlo simulation.

Parameters:

nint

Number of weights to generate.

distributionstr

Probability distribution for weight modification. Options: ‘chisquare’, ‘laplace’, ‘normal’, ‘random’, ‘triangular’, ‘uniform’.

paramsdict

Parameters for the chosen distribution. Check NumPy documentation for details.

num_samplesint, optional, default=1000

Number of samples to generate in the Monte Carlo simulation.

Returns:

ndarray

Array of modified criteria weights based on Monte Carlo simulation.

Example:

>>> n = 3
>>> modified_weights = monte_carlo_weights(n, num_samples=1000, distribution='normal', params={'loc': 0.5, 'scale': 0.1})
>>> print(modified_weights)

Perturbed matrix

pysensmcda.probabilistic.perturbed_matrix.perturbed_matrix(matrix: ndarray, simulations: int, precision: int = 6, perturbation_scale: float | ndarray = 0.1) ndarray[source]

Generate perturbed decision matrices based on the given initial decision matrix using random perturbation based on uniform distribution.

Parameters:

matrixndarray

2D array representing the initial decision matrix.

simulationsint

Number of perturbed decision matrix simulations to generate.

precisionint, optional, default=6

Precision for rounding the perturbed values from the decision matrix.

perturbation_scalefloat | np.ndarray, optional, default=0.1

Scale for random perturbation added to each value from the decision matrix. If float, then all decision matrix is modeled with the same perturbation scale. If ndarray, then each criterion is modeled with a given perturbation scale.

Returns:

ndarray

A ndarray of simulations length with perturbed decision matrices based on the given initial decision matrix.

Examples:

Example 1: Run with default parameters

>>> matrix = np.array([ [4, 3, 7], [1, 9, 6], [7, 5, 3] ])
>>> simulations = 1000
>>> results = perturbed_matrix(matrix, simulations)
>>> for r in results:
...     print(r)

Example 2: Run with given precision and perturbation scale

>>> matrix = np.array([ [4, 3, 7], [1, 9, 6], [7, 5, 3] ])
>>> simulations = 500
>>> precision = 3
>>> perturbation_scale = 1
>>> results = perturbed_matrix(matrix, simulations, precision, perturbation_scale)
>>> for r in results:
...     print(r)

Example 3: Run with perturbation scale defined for each column

>>> matrix = np.array([ [4, 3, 7], [1, 9, 6], [7, 5, 3] ])
>>> simulations = 100
>>> precision = 3
>>> perturbation_scale = np.array([0.5, 1, 0.4])
>>> results = perturbed_matrix(matrix, simulations, precision, perturbation_scale)
>>> for r in results:
...     print(r)

Example 4: Run with 2D perturbation scale array

>>> matrix = np.array([ [4, 3, 7], [1, 9, 6], [7, 5, 3] ])
>>> simulations = 100
>>> precision = 3
>>> perturbation_scale = np.array([ [0.4, 0.5, 1], [0.7, 0.3, 1.2], [0.5, 0.1, 1.5] ])
>>> results = perturbed_matrix(matrix, simulations, precision, perturbation_scale)
>>> for r in results:
...     print(r)

Perturbed weights

pysensmcda.probabilistic.perturbed_weights.perturbed_weights(weights: ndarray, simulations: int, precision: int = 6, perturbation_scale: float | ndarray = 0.1) ndarray[source]

Generate perturbed weights based on the given initial criteria weights based on the given perturbation scale and uniform distribution.

Parameters:

weightsndarray

1D array representing the existing criteria weights

simulationsint

Number of perturbed weight simulations to generate

precisionint, optional, default=6

Precision for rounding the perturbed weights

perturbation_scalefloat | np.ndarray, optional, default=0.1

Scale for random perturbation added to each weight. If float, then all criteria weights modeled with the same perturbation scale. If ndarray, then each criterion modeled with given perturbation scale.

Returns:

ndarray

A ndarray of perturbed weights based on the given criteria weights

Examples:

Example 1: Run with default parameters

>>> weights = np.array([0.3, 0.4, 0.3])
>>> simulations = 1000
>>> results = perturbed_weights(weights, simulations)
>>> for r in results:
...     print(r)

Example 2: Run with given precision and perturbation scale

>>> weights = np.array([0.3, 0.4, 0.3])
>>> simulations = 1000
>>> precision = 3
>>> perturbation_scale = 0.05
>>> results = perturbed_weights(weights, simulations, precision, perturbation_scale)
>>> for r in results:
...     print(r)

Example 3: Run with perturbation scale defined for each criterion

>>> weights = np.array([0.3, 0.4, 0.3])
>>> simulations = 1000
>>> precision = 3
>>> perturbation_scale = np.array([0.05, 0.1, 0.04])
>>> results = perturbed_weights(weights, simulations, precision, perturbation_scale)
>>> for r in results:
...     print(r)