从数据到概率质量函数-Matlab [英] From data to probability mass function - Matlab

查看:48
本文介绍了从数据到概率质量函数-Matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在给定数据向量的情况下,是否存在一个Matlab函数可以建立精确的概率质量函数(或概率密度函数)?

Is there a Matlab function which builds up the exact probability mass function (or probability density function) given a vector of data?

我的意思是这样的:

X = [1 2 4 1 4 3 2 3 4 1];
[x px] = a_function(X)
x = 
   1 2 3 4
px = 
   0.3 0.2 0.2 0.3

推荐答案

,您可以使用 accumarray

you can use accumarray

pmf = accumarray(X(:),1)./numel(X);
pmf = pmf./sum(pmf);

hist :

pmf = hist(X, max(X))' ./ numel(X);      

制表 :

t= tabulate(X);
pmf  = t(:, 3) ./ 100 ;

可能还有至少10种其他方式...

and there's probably at least 10 more ways doing so...

对于 px ,只需在制表中使用 px = unique(X) t(:, 1) 解决方案等...

for px just use px=unique(X), or t(:, 1) in the tabulate solution, etc...

这篇关于从数据到概率质量函数-Matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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