I have an NSArray which contains a large number of NSNumber objects (thousands). I use these numbers to build a nice line graph. The problem is, the graph uses every value, which makes the graph very sharp. It gets even worse the more values I have:

I want to be able to make this into a smoother graph, possibly throwing out those numbers that make it jagged looking. I want it to look like this:

Maybe it is late, but I am not thinking of a way to do this. Possibly looping through my values and throwing some of them out? The graph doesn’t need to be 100% accurate, it just needs to be a decent representation of the values.
EDIT:
Here is the method that I came up with using jrturton’s answer:
- (NSArray *)smoothedArray:(NSArray *)items {
int average = 0;
int i = 0;
int numberToAverageBy = 10;
NSMutableArray *newItems = [[[NSMutableArray alloc] init] autorelease];
// Loop
for (NSNumber *elevation in items) {
average += [elevation intValue];
i++;
if (i == numberToAverageBy) {
[newItems addObject:[NSNumber numberWithInt:average/numberToAverageBy]];
i = 0;
average = 0;
}//end
}//end for
return [NSArray arrayWithArray:newItems];
}//end
It worked perfectly!
You could take the average value of every 10 (or whatever you choose) elements in the array and use that to determine the points to plot. This would make the drawing quicker as well.