joint probability 2 arrays

16 ビュー (過去 30 日間)
meshesurf
meshesurf 2018 年 6 月 11 日
回答済み: Balaji Udayagiri 2022 年 7 月 8 日
Hi, I need to find the joint probability between 2 arrays of the same length and plot the 2 arrays togheter with the probability (as the colour) with scatter

回答 (1 件)

Balaji Udayagiri
Balaji Udayagiri 2022 年 7 月 8 日
Hi meshesurf
As per my understanding, you want to find the plot for the joint probability density functions.
Here is an example code that you can modify according to your need:
X = [1;2;1;1;2;1;1];
Y = [1;1;2;2;1;1;2];
%First find all list of values in X and Y seperately
% In this case I have taken only 1,2 as the possible values,
x_vals = [1,2];
y_vals = [1,2];
values={x_vals y_vals};
count=hist3([X,Y],'ctrs',values);%first count the values
p=count/sum(sum(count)); % then divide by the sum on all matrix value to get probability
%%
imagesc(p);
imagesc displays the probability values as differenc tcolour intensities.

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by