URGENT: How do I store thousands of data into arraylists and use them for calculations???
Hey guys, I'm doing this really complex problem from a past exam paper (got my real exam next monday!!!) which requires us to store thousands of data into array lists and do some calculations with them like mean, standard deviation etc...
The data is to be extracted from a URL - this I can do easily.
The data in the URL contains approximately 10,000 values individually for x (height), y (weight) and another column for Group.
(Sorry I can't post the link here since its an internal university link which can only be accessed by students....)
Rough Example...
Group, x (height, metres), y (weight, kg)
1, 1.61, 77
2, 1.56, 56
3, 1.58, 66
4, etc...etc...
Now heres the catch: some x and y values have the same Group numbers so:
Group 1 has some x and y values associated with it, Group 2 has some x and y values associated with it and so on...There are 100 Groups in total. But the thing is, the whole data set in the URL is not in order.... :mad:
Now how do I store all of this data in a single N x 3 array and calculate the mean x and y values for each Group 1,2,3,4,5 -> 100 ? :-o
Heres some data points for visualisation:
Group, x, y
2, 1.44, 56
2, 1.55, 66
3, 1.65, 65
6, 1.83, 85
6, 1.71, 78
3, 1.78, 89
3, 1.67, 67
3, 1.49, 52
5, 1.71, 72
5, 1.52, 61
8, 1.98, 103
8, 1.67, 90
1, 1.76, 85
Any help or advice would be greatly appreciated.
Many thanks in advance. :)
Re: URGENT: How do I store thousands of data into arraylists and use them for calculations???
Why do you have to store it in an array? If it's because this is an assignment, then you'll have to provide some more information: what have you tried? How would you do this by hand, with a piece of paper and a pencil?
I would just use a Map.
Re: URGENT: How do I store thousands of data into arraylists and use them for calculations???
Quote:
Originally Posted by
KevinWorkman
Why do you have to store it in an array? If it's because this is an assignment, then you'll have to provide some more information: what have you tried? How would you do this by hand, with a piece of paper and a pencil?
I would just use a Map.
Actually you can use any method you like for the assignment.
I've tried using individual array list for each of the data.
I used a for loop to sort each x and y values to the specified group using .collections(), but this is taking a very long time and a lot of code to do..
When you say map do you mean HasMap?
Could you please show me an example on how I would go about doing that?
Re: URGENT: How do I store thousands of data into arraylists and use them for calculations???