@@ -0,0 +1,1544 @@
+/*%0A * Copyright 2019 Dmitry Ustalov%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A *%0A */%0A%0Apackage org.nlpub.watset.util;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collection;%0Aimport java.util.List;%0Aimport java.util.Random;%0A%0A/**%0A * This interface includes utility functions which are useful in%0A * statistical evaluation of the results.%0A */%0Apublic interface Sampling %7B%0A    /**%0A     * Creates a bootstrapped dataset using sampling with replacement%0A     * from the given dataset. The dataset can be obtained using%0A     * %7B@link Collection#toArray(Object%5B%5D)%7D.%0A     *%0A     * @param dataset a dataset to sample from.%0A     * @param random  a random number generator.%0A     * @param %3CT%3E     an element class.%0A     * @return a sampled dataset.%0A     */%0A    static %3CT%3E Collection%3CT%3E sample(T%5B%5D dataset, Random random) %7B%0A        final List%3CT%3E sample = new ArrayList%3C%3E(dataset.length);%0A%0A        for (int i = 0; i %3C dataset.length; i++) %7B%0A            sample.add(dataset%5Brandom.nextInt(dataset.length)%5D);%0A        %7D%0A%0A        return sample;%0A    %7D%0A%7D%0A

Add Sampling