如何创建3D关节密度图MATLAB? [英] How to create 3D joint density plot MATLAB?

查看:153
本文介绍了如何创建3D关节密度图MATLAB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从数据创建联合密度函数时遇到问题.我所拥有的是股票中的队列大小,另存为两个向量:

I 'm having a problem with creating a joint density function from data. What I have is queue sizes from a stock as two vectors saved as:

X = [askQueueSize bidQueueSize];

然后我使用hist3函数创建3D直方图.这是我得到的: http://dl.dropbox.com/u/709705/hist-plot. png

I then use the hist3-function to create a 3D histogram. This is what I get: http://dl.dropbox.com/u/709705/hist-plot.png

我想要的是将Z轴归一化,使其从[0 1]开始.

What I want is to have the Z-axis normalized so that it goes from [0 1].

我该怎么做?还是有人在股票上具有出色的联合密度matlab 功能?

How do I do that? Or do someone have a great joint density matlab function on stock?

这类似于(如何在MatLab中绘制概率密度函数? ),但以2D模式显示.

This is similar (How to draw probability density function in MatLab?) but in 2D.

我想要的是使用x:ask queue, y:bid queue, z:probability的3D.

What I want is 3D with x:ask queue, y:bid queue, z:probability.

如果有人可以帮助我,将不胜感激,因为我在这里碰壁了.

Would greatly appreciate if someone could help me with this, because I've hit a wall over here.

推荐答案

在mathworks论坛的一个人的帮助下,这是我最终获得的绝佳解决方案:

With help from a guy at mathworks forum, this is the great solution I ended up with:

(data_x和data_y是要在hist3上计算的值)

(data_x and data_y are values, which you want to calculate at hist3)

x = min_x:step:max_x; % axis x, which you want to see
y = min_y:step:max_y; % axis y, which you want to see

[X,Y] = meshgrid(x,y); *%important for "surf" - makes defined grid*

pdf = hist3([data_x , data_y],{x y}); %standard hist3 (calculated for yours axis)
pdf_normalize = (pdf'./length(data_x)); %normalization means devide it by length of 
                                         %data_x (or data_y)
figure()
surf(X,Y,pdf_normalize) % plot distribution

这给了我3D的关节密度图.可以通过以下方法计算表面上的积分来检查:

This gave me the joint density plot in 3D. Which can be checked by calculating the integral over the surface with:

integralOverDensityPlot = sum(trapz(pdf_normalize));

当变量 step 变为零时,变量 integralOverDensityPlot 变为1.0

When the variable step goes to zero the variable integralOverDensityPlot goes to 1.0

希望这对某人有所帮助!

Hope this help someone!

这篇关于如何创建3D关节密度图MATLAB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆