wrong behavoir of BinCounts
- To: mathgroup at smc.vnet.net
- Subject: [mg8234] wrong behavoir of BinCounts
- From: Jose Luis Lugo Goytia <lugo at hplara.iquimica.unam.mx>
- Date: Thu, 21 Aug 1997 21:16:51 -0400
- Sender: owner-wri-mathgroup at wolfram.com
I am having the following problem with the BinCounts and
RangeCounts functions of the package Statistic`DataManipulation`
of the Mathematica 3.0, and would appreciate any tips you might have.
<<Statistics`DataManipulation`
and define the following function:
fun[a_List,q_Integer]:= Module[{aux1,aux2,amin,amax,h,pm,frq},
Clear[aux1,aux2,amin,amax,h,pm,frq];
aux1 = Flatten[a];
{amin,amax} = { Min[a], Max[a] };
h = N[(amax - amin)/q];
pm = Join[{amin}, Table[amin + (i + 1/2)*h, {i,1,q-2}], {amax}] //N;
frq = BinCounts[aux1,{amin,amax,h}]/Length[aux1] //N;
aux2 = Inner[List,pm,frq,List];
];
Interpolation[aux2] ]
but when use it for some matrix of data
A={{a_11,..,a_1n},...{a_m1,..,a_mn}}, and applied it to each row A[[k]],
for some index k, as Table[fun[A[[k]],10],{k,1,m}], then can't make the
Inner command because the Length[frq] is different of the Length[pm], and
therefore can't make the interpolation. Moreover, if divide the
segment {amin,amax} in q parts of size h, no always the Length[frq] is q,
but for other q1!=q is possible that the Length[frq]=q1.
However, for other matrix of data the function fun works.
How can I obtain Length[frq]=Length[pm] always? Any help appreciated.
Thanks in advance,
Jose Luis Lugo Goytia
Instituto de Quimica, UNAM
lugo at hplara.iquimica.unam.mx
lugo at turing.iquimica.unam.mx