Search in sources :

Example 21 with UniformRandomProvider

use of org.apache.commons.rng.UniformRandomProvider in project GDSC-SMLM by aherbert.

the class ErfTest method checkErfxHasLowError.

private static void checkErfxHasLowError(RandomSeed seed, BaseErf erf, double expected) {
    final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
    final int range = 8;
    double max = 0;
    for (int xi = -range; xi <= range; xi++) {
        for (int i = 0; i < 5; i++) {
            final double x = xi + rg.nextDouble();
            final double o = erf.erf(x);
            final double e = org.apache.commons.math3.special.Erf.erf(x);
            final double error = Math.abs(o - e);
            if (max < error) {
                max = error;
            }
            // logger.fine(FunctionUtils.getSupplier("x=%f, e=%f, o=%f, error=%f", x, e, o, error);
            Assertions.assertTrue(error < expected);
        }
    }
    logger.log(TestLogUtils.getRecord(Level.INFO, "erfx %s max error = %g", erf.name, max));
}
Also used : UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider)

Example 22 with UniformRandomProvider

use of org.apache.commons.rng.UniformRandomProvider in project GDSC-SMLM by aherbert.

the class SumFilterTest method intBlockSumNxNInternalAndStripedBlockSumNxNInternalReturnSameResult.

@SeededTest
void intBlockSumNxNInternalAndStripedBlockSumNxNInternalReturnSameResult(RandomSeed seed) {
    final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
    final SumFilter filter = new SumFilter();
    for (final int width : primes) {
        for (final int height : primes) {
            for (final int boxSize : boxSizes) {
                intCompareBlockSumNxNInternalAndStripedBlockSumNxNInternal(rg, filter, width, height, boxSize);
            }
        }
    }
}
Also used : UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest)

Example 23 with UniformRandomProvider

use of org.apache.commons.rng.UniformRandomProvider in project GDSC-SMLM by aherbert.

the class SumFilterTest method intBlockSumNxNInternalAndRollingBlockSumNxNInternalReturnSameResult.

@SeededTest
void intBlockSumNxNInternalAndRollingBlockSumNxNInternalReturnSameResult(RandomSeed seed) {
    final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
    final SumFilter filter = new SumFilter();
    for (final int width : primes) {
        for (final int height : primes) {
            for (final int boxSize : boxSizes) {
                intCompareBlockSumNxNInternalAndRollingBlockSumNxNInternal(rg, filter, width, height, boxSize);
            }
        }
    }
}
Also used : UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest)

Example 24 with UniformRandomProvider

use of org.apache.commons.rng.UniformRandomProvider in project GDSC-SMLM by aherbert.

the class SumFilterTest method intRollingBlockSum3x3InternalAndRollingBlockSumNxNInternalReturnSameResult.

@SeededTest
public void intRollingBlockSum3x3InternalAndRollingBlockSumNxNInternalReturnSameResult(RandomSeed seed) {
    final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
    final SumFilter filter = new SumFilter();
    for (final int width : primes) {
        for (final int height : primes) {
            intCompareRollingBlockSum3x3InternalAndRollingBlockSumNxNInternal(rg, filter, width, height);
        }
    }
}
Also used : UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest)

Example 25 with UniformRandomProvider

use of org.apache.commons.rng.UniformRandomProvider in project GDSC-SMLM by aherbert.

the class SumFilterTest method floatStripedBlockSum3x3AndStripedBlockSumNxNReturnSameResult.

@SeededTest
void floatStripedBlockSum3x3AndStripedBlockSumNxNReturnSameResult(RandomSeed seed) {
    final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
    final SumFilter filter = new SumFilter();
    for (final int width : primes) {
        for (final int height : primes) {
            floatCompareStripedBlockSum3x3AndStripedBlockSumNxN(rg, filter, width, height);
        }
    }
}
Also used : UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest)

Aggregations

UniformRandomProvider (org.apache.commons.rng.UniformRandomProvider)213 SeededTest (uk.ac.sussex.gdsc.test.junit5.SeededTest)145 SharedStateContinuousSampler (org.apache.commons.rng.sampling.distribution.SharedStateContinuousSampler)17 TimingService (uk.ac.sussex.gdsc.test.utils.TimingService)14 Rectangle (java.awt.Rectangle)13 DoubleDoubleBiPredicate (uk.ac.sussex.gdsc.test.api.function.DoubleDoubleBiPredicate)13 SpeedTag (uk.ac.sussex.gdsc.test.junit5.SpeedTag)12 TDoubleArrayList (gnu.trove.list.array.TDoubleArrayList)10 ArrayList (java.util.ArrayList)10 NormalizedGaussianSampler (org.apache.commons.rng.sampling.distribution.NormalizedGaussianSampler)9 StoredDataStatistics (uk.ac.sussex.gdsc.core.utils.StoredDataStatistics)8 CalibrationWriter (uk.ac.sussex.gdsc.smlm.data.config.CalibrationWriter)8 ContinuousSampler (org.apache.commons.rng.sampling.distribution.ContinuousSampler)6 ImageExtractor (uk.ac.sussex.gdsc.core.utils.ImageExtractor)6 LocalList (uk.ac.sussex.gdsc.core.utils.LocalList)6 Gaussian2DFunction (uk.ac.sussex.gdsc.smlm.function.gaussian.Gaussian2DFunction)6 FloatProcessor (ij.process.FloatProcessor)5 ErfGaussian2DFunction (uk.ac.sussex.gdsc.smlm.function.gaussian.erf.ErfGaussian2DFunction)5 TimingResult (uk.ac.sussex.gdsc.test.utils.TimingResult)5 File (java.io.File)4