public static <T> Set<T> getRandomSubset(Set<? extends T> set, int size, Random rg) {
        Set<T> subset = new LinkedHashSet<>();
        getRandomSubset(set, size, rg, subset);
        return subset;
    }
public static < T > Set < T > getRandomSubset ( Set < ? extends T > set , int size , Random rg ) { Set < T > subset = new LinkedHashSet < > ( ) ; getRandomSubset ( set , size , rg , subset ) ; return subset ; }
<p>
Selects a random subset of a specific size from a given set (uniformly distributed).
Applies a full scan algorithm that iterates once through the given set and selects each item with probability
(#remaining to select)/(#remaining to scan). It can be proven that this algorithm creates uniformly distributed
random subsets (for example, a proof is given <a href="http://eyalsch.wordpress.com/2010/04/01/random-sample">here</a>).
In the worst case, this algorithm has linear time complexity with respect to the size of the given set.
</p>
<p>
The generated subset is stored in a newly allocated {@link LinkedHashSet}.
</p>

@see <a href="http://eyalsch.wordpress.com/2010/04/01/random-sample">http://eyalsch.wordpress.com/2010/04/01/random-sample</a>
@param <T> type of elements in randomly selected subset
@param set set from which a random subset is to be selected
@param size desired subset size, should be a number in [0,|set|]
@param rg random generator
@throws IllegalArgumentException if an invalid subset size outside [0,|set|] is specified
@return random subset stored in a newly allocated {@link LinkedHashSet}.