Borrar filtros
Borrar filtros

Monte Carlo sampling for multi-parameter Sensitivity Analysis

3 visualizaciones (últimos 30 días)
I want to conduct a Sensitivity Analysis in another program and I want to create the inputs for this using Matlab.
I have 6 parameters, each have a value range and a probability distribution (normal, triangular, ...) assigned to them. Now I need to sample from these distributions using Monte Carlo sampling in order to get like 10 parameter combinations to use for my input. But this picking of parameter combinations needs to be based on the interaction of the probability distributions.
I believe there is something like a "take 1 million random combinations of the 6 parameters and take these specific combinations"-approach, but I couldn't find anything similar in literature yet.

Respuesta aceptada

Nipun
Nipun el 22 de Mayo de 2024
Hi Maximilian,
I understand that you are trying to perform a Monte Carlo sampling of 6 parameters, each with its own value range and probability distribution, to generate parameter combinations for sensitivity analysis in another program. You're looking for a way to sample these parameters based on their distributions to obtain specific combinations for your analysis.
To achieve this in MATLAB, you can use various functions depending on the type of distribution each parameter follows. For example, randn for normal distributions, rand for uniform distributions, and custom functions for triangular or other distributions. Here's a basic approach to generate 10 random parameter combinations from specified distributions:
  1. Define the distributions for each parameter. For simplicity, let's assume two parameters follow normal distributions (normrnd), two follow uniform distributions (unifrnd), and two follow triangular distributions (for which we'll define a custom sampling function).
  2. Sample from these distributions using Monte Carlo sampling. You'll generate a large number of combinations (e.g., 1 million) and then select a subset (e.g., 10) for your analysis.
Here is an example implementation in MATLAB:
% Number of samples
N = 1e6; % For the initial large sampling
N_final = 10; % Number of final combinations to select
% Parameter distributions
% Assuming param1 and param2 follow normal distributions, param3 and param4 follow uniform distributions,
% and param5 and param6 follow triangular distributions
% Normal distributions parameters
mu1 = 5; sigma1 = 1; % Mean and standard deviation for param1
mu2 = 10; sigma2 = 2; % Mean and standard deviation for param2
% Uniform distributions parameters
a3 = 0; b3 = 1; % Lower and upper bounds for param3
a4 = 5; b4 = 15; % Lower and upper bounds for param4
% For triangular distribution, define a custom function or use an existing one if available
% Here's a simple implementation assuming a continuous uniform distribution as an example
triangularSample = @(min, mode, max, N) min + (max - min) .* sqrt(rand(N, 1) .* rand(N, 1));
% Sampling
param1 = normrnd(mu1, sigma1, [N, 1]);
param2 = normrnd(mu2, sigma2, [N, 1]);
param3 = unifrnd(a3, b3, [N, 1]);
param4 = unifrnd(a4, b4, [N, 1]);
param5 = triangularSample(1, 2, 3, N); % Example parameters for triangular distribution
param6 = triangularSample(2, 4, 6, N); % Example parameters for another triangular distribution
% Combine the parameters into a single matrix
params = [param1, param2, param3, param4, param5, param6];
% Select N_final random combinations
idx = randperm(N, N_final);
selected_combinations = params(idx, :);
% Now selected_combinations contains 10 sets of parameter combinations sampled based on their distributions
This code snippet provides a framework you can adapt based on the specific distributions and parameters of your analysis. Note that for the triangular distribution, you may need to implement a more appropriate sampling method or find a MATLAB function/library that supports it directly if the simple example provided does not suit your needs.
Refer to the following MathWorks documentation for more information on "randn", "rand", "normrnd" and "unifrnd" functions:
  1. "randn" function : https://in.mathworks.com/help/matlab/ref/randn.html
  2. "rand" function : https://in.mathworks.com/help/matlab/ref/rand.html
  3. "normrnd" function : https://in.mathworks.com/help/stats/normrnd.html
  4. "unifrnd" function : https://in.mathworks.com/help/stats/unifrnd.html
Hope this helps.
Regards,
Nipun

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by