/*
 * ARX: Powerful Data Anonymization
 * Copyright 2012 - 2018 Fabian Prasser and contributors
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

package org.deidentifier.arx.reliability;

/**
 * Class supporting parameter calculations and translations.
 * 
 * @author Fabian Prasser
 */
public class ParameterTranslation {
    
    /** Relative threshold precision*/
    public static final double RELATIVE_THRESHOLD_PRECISION = 0.01d;

    /**
     * Returns a minimal class size for the given risk threshold
     * @param threshold
     * @return
     */
    public static int getSizeThreshold(double riskThreshold) {
        
        // Check
        if (riskThreshold < 0d || riskThreshold >1d) {
            throw new IllegalArgumentException("Invalid threshold");
        }
        
        // Special case
        if (riskThreshold == 0d) {
            return Integer.MAX_VALUE;
        }
        
        // Calculate
        double size = 1d / riskThreshold;
        double floor = Math.floor(size);
        if ((1d / floor) - (1d / size) >= RELATIVE_THRESHOLD_PRECISION * riskThreshold) {
            floor += 1d;
        }
        
        // Return
        return (int)floor;
    }
    
    /**
     * Returns the effective risk threshold
     * @param riskThreshold
     * @return
     */
    public static double getEffectiveRiskThreshold(double riskThreshold) {
        return 1d / getSizeThreshold(riskThreshold);
    }
}

@@ -104,200 +104,166 @@
 %0A * 
-This program is free software: you can redistribute it and/or modify%0D%0A * it under the terms of the GNU General Public License as published by%0D%0A * the Free Software Foundation, either version 3
+Licensed under the Apache License, Version 2.0 (the %22License%22);%0D%0A * you may not use this file except in compliance with the License.%0D%0A * You may obtain a copy
  of 
@@ -277,133 +277,214 @@
 ense
-, or
+ at
 %0D%0A * 
-(at your option) any later version.%0D%0A * %0D%0A * This program is distributed in the hope that it will be useful
+%0D%0A * http://www.apache.org/licenses/LICENSE-2.0%0D%0A * %0D%0A * Unless required by applicable law or agreed to in writing, software%0D%0A * distributed under the License is distributed on an %22AS IS%22 BASIS
 ,%0D%0A *
- but
  WIT
@@ -492,327 +492,186 @@
 OUT 
-ANY 
 WARRANT
-Y; without even the implied warranty of%0D%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the%0D%0A * GNU General Public License for more details.%0D%0A * %0D%0A * You should have received a copy of the GNU General Public License%0D%0A * along with this program. If not, see %3Chttp://www.gnu.org/l
+IES OR CONDITIONS OF ANY KIND, either express or implied.%0D%0A * See the License for the specific language governing permissions and%0D%0A * limitations under the L
 icense
-s/%3E
 .%0D%0A */%0D%0A
 %0D%0Apa
@@ -666,18 +666,16 @@
 .%0D%0A */%0D%0A
-%0D%0A
 package 

Fix license header