1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.commons.math.distribution; 19 20 /** 21 * Test cases for {@link ZipfDistribution}. 22 * Extends IntegerDistributionAbstractTest. See class javadoc for 23 * IntegerDistributionAbstractTest for details. 24 * 25 * @version $Revision: 762087 $ $Date: 2009-04-05 10:20:18 -0400 (Sun, 05 Apr 2009) $ 26 */ 27 public class ZipfDistributionTest extends IntegerDistributionAbstractTest { 28 public ZipfDistributionTest(String name) { 29 super(name); 30 } 31 32 //-------------- Implementations for abstract methods ----------------------- 33 34 /** Creates the default discrete distribution instance to use in tests. */ 35 @Override 36 public IntegerDistribution makeDistribution() { 37 return new ZipfDistributionImpl(10, 1); 38 } 39 40 /** Creates the default probability density test input values */ 41 @Override 42 public int[] makeDensityTestPoints() { 43 return new int[] {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; 44 } 45 46 /** Creates the default probability density test expected values */ 47 @Override 48 public double[] makeDensityTestValues() { 49 return new double[] {0d, 0d, 0.3414d, 0.1707d, 0.1138d, 0.0854d, 0.0683d, 50 0.0569d, 0.0488d, 0.0427d, 0.0379d, 0.0341d, 0d}; 51 } 52 53 /** Creates the default cumulative probability density test input values */ 54 @Override 55 public int[] makeCumulativeTestPoints() { 56 return makeDensityTestPoints(); 57 } 58 59 /** Creates the default cumulative probability density test expected values */ 60 @Override 61 public double[] makeCumulativeTestValues() { 62 return new double[] {0d, 0.0000d, 0.3414d, 0.5121d, 0.6259d, 0.7113d, 63 0.7796d, 0.8365d, 0.8852d, 0.9279d, 0.9659d, 1d, 1d}; 64 } 65 66 /** Creates the default inverse cumulative probability test input values */ 67 @Override 68 public double[] makeInverseCumulativeTestPoints() { 69 return new double[] {0, 0.001d, 0.010d, 0.025d, 0.050d, 0.3414d, 0.3415d, 0.999d, 70 0.990d, 0.975d, 0.950d, 0.900d, 1}; 71 } 72 73 /** Creates the default inverse cumulative probability density test expected values */ 74 @Override 75 public int[] makeInverseCumulativeTestValues() { 76 return new int[] {0, 0, 0, 0, 0, 0, 1, 9, 9, 9, 8, 7, 10}; 77 } 78 }