Java Code Examples for org.apache.commons.math.exception.NotStrictlyPositiveException

Following code examples demonstrate how to use org.apache.commons.math.exception.NotStrictlyPositiveExceptionfrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.apache.commons.math.exception.NotStrictlyPositiveExceptionand various code implementation of this class.

  






  public MultidimensionalCounter(int... size)
  {
    dimension = size.length;
    this.size = copyOf(size, dimension);
    
    uniCounterOffset = new int[dimension];
    
    last = (dimension - 1);
    int tS = size[last];
    for (int i = 0; i < last; i++) {
      int count = 1;
      for (int j = i + 1; j < dimension; j++) {
        count *= size[j];
      }
      uniCounterOffset[i] = count;
      tS *= size[i];
    }
    uniCounterOffset[last] = 0;
    
    if (tS <= 0) {
      throw new NotStrictlyPositiveException(Integer.valueOf(tS));
    }
    
    totalSize = tS;
  } 


    public void testPreconditions() {
        try {
            new ZipfDistributionImpl(0, 1);
            Assert.fail("NotStrictlyPositiveException expected");
        } catch (NotStrictlyPositiveException e) {
        }
        try {
            new ZipfDistributionImpl(1, 0);
            Assert.fail("NotStrictlyPositiveException expected");
        } catch (NotStrictlyPositiveException e) {
        }
    } 

    public void testPreconditions() {
        try {
            new CauchyDistributionImpl(0, 0);
            fail("Cannot have zero scale");
        } catch (NotStrictlyPositiveException ex) {
        }
        try {
            new CauchyDistributionImpl(0, -1);
            fail("Cannot have negative scale");
        } catch (NotStrictlyPositiveException ex) {
        }
    } 

    public void testAlpha() {
        WeibullDistribution dist = new WeibullDistributionImpl(1, 2);
        assertEquals(1, dist.getShape(), 0);
        try {
            dist = new WeibullDistributionImpl(0, 2);
            fail("NotStrictlyPositiveException expected");
        } catch (NotStrictlyPositiveException e) {
        }
    } 

    public void testBeta() {
        WeibullDistribution dist = new WeibullDistributionImpl(1, 2);
        assertEquals(2, dist.getScale(), 0);
        try {
            dist = new WeibullDistributionImpl(1, 0);
            fail("NotStrictlyPositiveException expected");
        } catch (NotStrictlyPositiveException e) {
        }
    } 

  















  public int nextInt(int n)
  {
    if (n <= 0) {
      throw new NotStrictlyPositiveException(Integer.valueOf(n));
    }
    int result = (int)(nextDouble() * n);
    return result < n ? result : n - 1;
  } 

    
    public Logistic(double k,
                    double m,
                    double b,
                    double q,
                    double a,
                    double n) {
        if (n <= 0) {
            throw new NotStrictlyPositiveException(n);
        }

        this.k = k;
        this.m = m;
        this.b = b;
        this.q = q;
        this.a = a;
        this.n = n;
    }