View Javadoc
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    *      https://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  /*
19   * This is not the original file distributed by the Apache Software Foundation
20   * It has been modified by the Hipparchus project
21   */
22  package org.hipparchus.distribution.continuous;
23  
24  import org.hipparchus.util.Precision;
25  import org.junit.jupiter.api.Test;
26  
27  import static org.junit.jupiter.api.Assertions.assertEquals;
28  import static org.junit.jupiter.api.Assertions.assertTrue;
29  
30  /**
31   * Test cases for LogisticsDistribution.
32   */
33  public class LogisticsDistributionTest extends RealDistributionAbstractTest {
34  
35      @Test
36      void testParameters() {
37          LogisticDistribution d = makeDistribution();
38          assertEquals(2, d.getLocation(), Precision.EPSILON);
39          assertEquals(5, d.getScale(), Precision.EPSILON);
40      }
41  
42      @Test
43      void testSupport() {
44          LogisticDistribution d = makeDistribution();
45          assertTrue(Double.isInfinite(d.getSupportLowerBound()));
46          assertTrue(Double.isInfinite(d.getSupportUpperBound()));
47          assertTrue(d.isSupportConnected());
48      }
49  
50      @Override
51      public LogisticDistribution makeDistribution() {
52          return new LogisticDistribution(2, 5);
53      }
54  
55      @Override
56      public double[] makeCumulativeTestPoints() {
57          return new double[] {
58              -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5
59          };
60      }
61  
62      @Override
63      public double[] makeDensityTestValues() {
64          return new double[] {
65              0.03173698, 0.03557889, 0.03932239, 0.04278194, 0.04575685, 0.04805215,
66              0.04950331, 0.05000000, 0.04950331, 0.04805215, 0.04575685
67          };
68      }
69  
70      @Override
71      public double[] makeCumulativeTestValues() {
72          return new double[] {
73              0.1978161, 0.2314752, 0.2689414, 0.3100255, 0.3543437, 0.4013123,
74              0.4501660, 0.5000000, 0.5498340, 0.5986877, 0.6456563
75          };
76      }
77  
78  }
79