I like Lyndsey Scott's answer so thought I'd implement it so that you can still get the original index of the word.
If you have an array of 10 items and you want 3 of them (combined equally) to have an 80% chance of being chosen then that means the other 7 have a chance of 20%.
So...
I worked it out like this...
We know 7 is 20%. So 100% is 35. 80% of 35 is 28.
Ideally you should be doing this calculation in the app not on paper :) Maybe store the individual weights of each item in an array or something. That way you can create the weighted array dynamically for any number of items and different weights etc...
You'll need 28 of the other 3 (in total) so 9 of two of them and 10 of the other. (Let's make it 9 each for ease).
So you can do like this...
NSMutableArray *weightedArray = [NSMutableArray array];
for (int i=0 ; i<originalArray.count ; ++i) {
if (i == 3 || i == 7 || i == 9) {
for (int count=0 ; count<9 ; ++count) {
[weightedArray addObject:array[i]];
}
} else {
[weightedArray addObject:array[i]];
}
}
// Now you can select from the weighted array.
id randomObject = weightedArray[arc4random_uniform(weightedArray.count)];
//Index of object
NSUInteger origIndex = [originalArray indexOfObject:randomObject];
It might be an idea to store the individual weights or something and then calculate the number you need to put at run time.
As Sandy Chapman pointed out in the comments you could also created a weighted array of indices for the original array so you would have...
[0, 1, 2, 3, 3, 3, ..., 4, 5, 6, 7, 7, 7..., 8, 9, 9, 9, 9, ..., 10]
That way you can get the index without having to get the original item.
Either way will work.