Borrar filtros
Borrar filtros

Calculating the marginal distribution from the joint distribution table

6 visualizaciones (últimos 30 días)
skyline
skyline el 5 de Jun. de 2017
Comentada: Jan el 5 de Jul. de 2017
I would like to write down a function that generates the marginal distribution table from the joint distribution table.
Specifically, suppose I have a table
A =
[0.1 0 0.1; 0.1 0.1 0.1; 0.2 0 0.2; 0.2 0.1 0.2; 0.2 0.2 0.2]
where the first column is denoted x and the second column is denoted y
Then I would like to create a marginal distribution table where
- the first column is the distinct values of the first column of A (that is, the distinct values of x)
- the second column is the marginal distribution of x.
For example, the first (1,2)th element is the average of the entry of the third column of A where the first column is 0.1 (i,e. the marginal distribution for 0.1)
Please advise.
  1 comentario
Jan
Jan el 5 de Jul. de 2017
"Please advice" : The most important advice is that you should stop to remove the text of your questions, after they have been answered. This is disliked here and counterproductive. The answers are posted to let the community profit from the solution. Editing the question away converts the thread to confusing junk.
Please, skyline, stop this deleting.

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 5 de Jun. de 2017
I’m not quite certain what you want.
See if this works:
A = [0.1 0 0.1; 0.1 0.1 0.1; 0.2 0 0.2; 0.2 0.1 0.2; 0.2 0.2 0.2];
[Au,~,ic] = unique(A(:,1));
Result = accumarray(ic, A(:,3), [], @mean);
Output = [Au, Result]
Output =
0.1 0.1
0.2 0.2

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by