0
votes

I have two normal distributions and i am trying to make a volumetric surface from them. I got the following graph

enter image description here

clear; clc;

nsamp = 100000;

%

% Basic variables

%

m1=2.724;

dp1=0.375;

R = normrnd(m1,dp1, nsamp, 1);

m2=1.345;

dp2=0.135;

S = normrnd(m2,dp2, nsamp, 1);

%

Z = R - S;


    I = (Z < 0);

pf = sum(I)/nsamp

beta = -norminv(pf)

%

% Histograms

hist(S,20)

hold on

hist(R,40)

set(findobj('Type','patch'),'Facecolor','none','Edgecolor','black')

set(gca,'Fontsize',18,'Fontname','euclid')

xlabel('R & S')


figure

scatterhist(R,S)

xlabel('R'),ylabel('S')

and i would like to make a 3D surface and the points in red to remain in red and the blue points in blue. Can someone help me? Regards

1
"volume" implies three dimensions. What would you like the third dimension to represent? - Floris
<jitkomut.lecturer.eng.chula.ac.th/matlab/_images/gaussian8.png The frequency of the result function density. - blitzstat
That is the pretended surface. But the colors are not. I would like to be blue and red only. Thanks mate! - blitzstat
Sorry to keep bugging for details - but how do you want the colors to show up. Do you want two surfaces - one all blue, and one all red? Or do you want a single Gaussian that is more blue when it's blue, and more red when it's red? It's hard to read your mind on this... - Floris
If you run that code you can see two types of points: red and blue. I would like a single Gaussian surface that is blue and red at the same time, according to the I vector. I dont know if i explained myself in the proper way... Sorry mate and thanks a lot for your dedication and time! :) - blitzstat

1 Answers

0
votes

I can't write a tested solution right now - not access to Matlab license server. But you have two problems here.

The first is to create a surface plot of density. You can use the hist3 function for the this - and if you return the values of the bins you can control the plotting yourself:

[N C] = histc(X)

(I'm sorry it is not clear to me what you really want to plot - is it R, S, Z, or R+S? that's why I used X).

Then to color the graph, you can use patch coloring - see http://www.mathworks.com/help/matlab/visualize/specifying-patch-coloring.html for how to do that.

The combination of these two should get you a long way there... but it's still a little unclear what you really want to do. I hope these hints help you on your way.