数据统计 tabul

Scilab Help >> Statistics > Summaries > tabul

tabul

frequency of values of a matrix or vector    

[m]=tabul(X [,order])

order:  ‘i’ 升序

          ‘d’ 降序,默认值

统计向量或矩阵中 数据元素出现的次数,对字符矩阵统计每个字符串的统计信息

X = [2 8 0 3 7 6 8 7 9 1 6 7 7 2 5 2 2 2 9 7]
m1 = tabul(X)
m2 = tabul(X, "i")

 输出

-->m2 = tabul(X, "i")
m2 =

0. 1.
1. 1.
2. 5.
3. 1.
5. 1.
6. 2.
7. 5.
8. 2.
9. 2.

 

 

X = ["b" "bab" "a" "A" "A1" "a" "aa" "aa" "aa" "A" "b"]
m = tabul(X,"i")

输出

X =

!b bab a A A1 a aa aa aa A b !

m =


m(1)

!A !
! !
!A1 !
! !
!a !
! !
!aa !
! !
!b !
! !
!bab !

m(2)

2.
1.
2.
3.
2.
1.

 

n = 5000;
X = grand(n,1,"bin",50,0.5);
m = tabul(X,"i");
clf()
plot2d3(m(:,1), m(:,2)/n)
xtitle("empirical probabilities of B(70,0.5)")

运行结果:

 

 

posted @ 2015-03-22 13:04  JkReader  阅读(236)  评论(0编辑  收藏  举报