Filter löschen
Filter löschen

Calculating the marginal distribution from the joint distribution table

6 Ansichten (letzte 30 Tage)
skyline
skyline am 5 Jun. 2017
Kommentiert: Jan am 5 Jul. 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 Kommentar
Jan
Jan am 5 Jul. 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 5 Jun. 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

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by