Borrar filtros
Borrar filtros

Convolution of two matrixes of PDF values

5 visualizaciones (últimos 30 días)
Daniel
Daniel el 2 de Mayo de 2024
Respondida: Balavignesh el 20 de Mayo de 2024
Hello,
I'm trying to write a function that looks like something like this: convolved_matrix = convolve_matrixes(matrix1, matrix2), where the matrixes are N x 2 large (N rows and 2 columns). These matrixes is containing PDF values where on the first column contains the indexes and the second column contains the probabilities. So my question is how can i obtain a matrix that contains the correct convolution with correct index values and probability values between the inputed matrixes?
  1 comentario
John D'Errico
John D'Errico el 2 de Mayo de 2024
Is the first column a set of equally spaced values? Or are they scattered, unequally spaced? The answer would be hugely different depending on your response.

Iniciar sesión para comentar.

Respuestas (1)

Balavignesh
Balavignesh el 20 de Mayo de 2024
Hi Daniel,
It is my understanding that you wish to find the convolution of two matrices containing probability distribution values. The convolution of two probability distributions represents the probability distribution of the sum of two independent random variables represented by these distributions.
Assuming your matrices are properly structured with indices and probabilities, the convolution process will involve calculating the sum of all possible pairs of indices and their corresponding products of probabilities. The resulting convolved matrix will have its indices ranging from the sum of the minimum indices to the sum of the maximum indices of the input matrices. Additionally, the probabilities will be the sum of the products of probabilities for each pair of indices that sum to a given index.
Have a look at the following code snippet to better understand this:
% Dummy Matrices
matrix1 = [1 0.2; 2 0.5; 3 0.3];
matrix2 = [1 0.4; 2 0.6];
% Extract indices and probabilities from the input matrices
indices1 = matrix1(:, 1);
probs1 = matrix1(:, 2);
indices2 = matrix2(:, 1);
probs2 = matrix2(:, 2);
% Calculate the range of the convolved indices
minIndex = min(indices1) + min(indices2);
maxIndex = max(indices1) + max(indices2);
convolvedIndices = (minIndex:maxIndex)';
% Initialize the convolved probabilities vector
convolvedProbs = zeros(length(convolvedIndices), 1);
% Perform the convolution operation
for i = 1:length(indices1)
for j = 1:length(indices2)
% Find the convolved index for the current pair of indices
convolvedIndex = indices1(i) + indices2(j);
% Find the position of this index in the convolvedIndices array
position = convolvedIndex - minIndex + 1;
% Add the product of the probabilities to the corresponding position
convolvedProbs(position) = convolvedProbs(position) + probs1(i) * probs2(j);
end
end
% Combine the convolved indices and probabilities into the output matrix
convolvedMatrix = [convolvedIndices, convolvedProbs];
disp(convolvedMatrix)
2.0000 0.0800 3.0000 0.3200 4.0000 0.4200 5.0000 0.1800
You might find the below documentation link useful:
Hope that helps!
Balavignesh

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by