code: public static FlatDataCollection randomSampling(FlatDataList idList, int n, boolean withReplacement) {
          FlatDataList sampledIds = new FlatDataList();
          
          int populationN = idList.size();
          
          for(int i=0;i<n;) {
              if(withReplacement==false && populationN<=n) {
                  /* if replacement is not allowed and we already sampled everything that it can stop */
                  break;
              }
              
              int randomPosition = PHPMethods.mt_rand(0, populationN-1);
              
              Object pointID = idList.get(randomPosition);
              
              if(withReplacement==false && sampledIds.contains(pointID)) {
                  continue;
              }
  
              sampledIds.add(pointID);
              ++i;
              
              
          }
      
          return sampledIds.toFlatDataCollection();
      }
docs: Samples n ids by using SimpleRandomSampling (Simple Random Sampling).
  
  @param idList
  @param n
  @param withReplacement
  @return