How to compute Frequency distributions ?

P

Pierre8r

Hello,

How to compute Frequency distributions ?

I have a sample array of doubles.
It's just a sample, the real array it's a lot bigger.

double[] array = { 10.1, 34.0, 15.0, 22.5, 24.2, 31.0, 32.0, 37.0 };

I need to know the frequency for 4 categories.

Which is the frequency for the doubles < 10 ?
Which is the frequency for the doubles >= 10 and < 20?
Which is the frequency for the doubles >= 20 and < 30 ?
Which is the frequency for the doubles >= 30 ?

Thanks,

Pierre8r
 
S

Stefan Ram

Pierre8r said:
double[] array = { 10.1, 34.0, 15.0, 22.5, 24.2, 31.0, 32.0, 37.0 };
Which is the frequency for the doubles < 10 ?
Which is the frequency for the doubles >= 10 and < 20?
Which is the frequency for the doubles >= 20 and < 30 ?
Which is the frequency for the doubles >= 30 ?

for( int i = 0; i < array.length; ++i )++count[( int )( array[ i ]/ 10. )];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top