001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.commons.math.distribution;
019
020 /**
021 * Test cases for {@link ZipfDistribution}.
022 * Extends IntegerDistributionAbstractTest. See class javadoc for
023 * IntegerDistributionAbstractTest for details.
024 *
025 * @version $Revision: 762087 $ $Date: 2009-04-05 10:20:18 -0400 (Sun, 05 Apr 2009) $
026 */
027 public class ZipfDistributionTest extends IntegerDistributionAbstractTest {
028 public ZipfDistributionTest(String name) {
029 super(name);
030 }
031
032 //-------------- Implementations for abstract methods -----------------------
033
034 /** Creates the default discrete distribution instance to use in tests. */
035 @Override
036 public IntegerDistribution makeDistribution() {
037 return new ZipfDistributionImpl(10, 1);
038 }
039
040 /** Creates the default probability density test input values */
041 @Override
042 public int[] makeDensityTestPoints() {
043 return new int[] {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
044 }
045
046 /** Creates the default probability density test expected values */
047 @Override
048 public double[] makeDensityTestValues() {
049 return new double[] {0d, 0d, 0.3414d, 0.1707d, 0.1138d, 0.0854d, 0.0683d,
050 0.0569d, 0.0488d, 0.0427d, 0.0379d, 0.0341d, 0d};
051 }
052
053 /** Creates the default cumulative probability density test input values */
054 @Override
055 public int[] makeCumulativeTestPoints() {
056 return makeDensityTestPoints();
057 }
058
059 /** Creates the default cumulative probability density test expected values */
060 @Override
061 public double[] makeCumulativeTestValues() {
062 return new double[] {0d, 0.0000d, 0.3414d, 0.5121d, 0.6259d, 0.7113d,
063 0.7796d, 0.8365d, 0.8852d, 0.9279d, 0.9659d, 1d, 1d};
064 }
065
066 /** Creates the default inverse cumulative probability test input values */
067 @Override
068 public double[] makeInverseCumulativeTestPoints() {
069 return new double[] {0, 0.001d, 0.010d, 0.025d, 0.050d, 0.3414d, 0.3415d, 0.999d,
070 0.990d, 0.975d, 0.950d, 0.900d, 1};
071 }
072
073 /** Creates the default inverse cumulative probability density test expected values */
074 @Override
075 public int[] makeInverseCumulativeTestValues() {
076 return new int[] {0, 0, 0, 0, 0, 0, 1, 9, 9, 9, 8, 7, 10};
077 }
078 }