Frequency distribution table

Hi ,

I am trying to create a frequency distribution table, which calculates the frequency for values within a class. For eg: -1 to -0.8, -0.8 to -0.6 till .6 to .8; .8 to 1

I think s:( f:-1f+0.2f*til 10) helps me get the intervals

Now i have the values in a table t1, from which i want to calculate the frequency of each values given the above interval.

Your help on this is much appreciated.

Thanks in advance

A

Hi,

Something like this:

f:-1f+0.2*til 10

v: -1+100?2.0

count each group f f bin v

WBR, Andrey.

??? 2015 ?., 11:48:35 UTC+3 ??? Antriksh Patawari ???:

Hi ,

I am trying to create a frequency distribution table, which calculates the frequency for values within a class. For eg: -1 to -0.8, -0.8 to -0.6 till .6 to .8; .8 to 1

I think s:( f:-1f+0.2f*til 10) helps me get the intervals

Now i have the values in a table t1, from which i want to calculate the frequency of each values given the above interval.

Your help on this is much appreciated.

Thanks in advance

A

Thanks so much for your super quick reply Andrey.
However, there is one small thing:

for table with col name, for eg:

a     b     c

0.1  0.2  0.15

0.2  0.35  1

-0.5 -0.4  0

the col name seems to be a prob, leading to the error `type

Sorry for sounding so amateurish on this.

Again, help is much appreciated.

-A

Can use xbar also, http://code.kx.com/wiki/Reference/xbar

 
q)select count i by .2 xbar col1 from ( col1:-1+100?2.0)

col1 x
-1  11
-0.8 7
-0.6 2
-0.4 11
-0.2 14
0   12
0.2 11
0.4 16
0.6 6
0.8 10

Terry

To clarify, the xbar/tabular solution is fine (and most readable) for a single column operation.

Andrey’s solution works best for multiple columns at once.

tab:( col1:-1+100?2.0;col2:-1+100?2.0;col3:-1+100?2.0)

f:-1f+0.2*til 10;

q)(f)!flip value each til[count f]#/:count’'[group each f bin flip tab]

f   col1 col2 col3
-1  10   12   9
-0.8 7    11   11
-0.6 10   8    9
-0.4 12   8    11
-0.2 4    17   12
0   14   10   9
0.2 10   8    13
0.4 6    11   10
0.6 13   5    5
0.8 14   10   11

Terry