Class UnitSphereSampler

    • Field Detail

      • THREE_D

        private static final int THREE_D
        The dimension for 3D sampling.
        See Also:
        Constant Field Values
      • MASK_BIT_2

        private static final int MASK_BIT_2
        The mask to extract the second bit from an integer (naming starts at bit 1 for the least significant bit). The masked integer will have a value 0 or 2.
        See Also:
        Constant Field Values
      • delegate

        private final UnitSphereSampler delegate
        The internal sampler optimised for the dimension.
    • Constructor Detail

      • UnitSphereSampler

        @Deprecated
        public UnitSphereSampler​(int dimension,
                                 UniformRandomProvider rng)
        This instance delegates sampling. Use the factory method of(UniformRandomProvider, int) to create an optimal sampler.
        Parameters:
        dimension - Space dimension.
        rng - Generator for the individual components of the vectors. A shallow copy will be stored in this instance.
        Throws:
        java.lang.IllegalArgumentException - If dimension <= 0
      • UnitSphereSampler

        private UnitSphereSampler​(UnitSphereSampler delegate)
        Private constructor used by deprecated constructor used to prevent partially initialized object if the construction of the delegate throws. In future versions the public constructor should be removed and the class made abstract.
        Parameters:
        delegate - Delegate.
      • UnitSphereSampler

        private UnitSphereSampler()
        Private constructor used by sub-class specialisations. In future versions the public constructor should be removed and the class made abstract.
    • Method Detail

      • sample

        public double[] sample()
        Description copied from interface: ObjectSampler
        Create an object sample.
        Specified by:
        sample in interface ObjectSampler<double[]>
        Returns:
        a random normalized Cartesian vector.
        Since:
        1.4
      • nextVector

        @Deprecated
        public double[] nextVector()
        Deprecated.
        Returns:
        a random normalized Cartesian vector.
      • of

        public static UnitSphereSampler of​(UniformRandomProvider rng,
                                           int dimension)
        Create a unit sphere sampler for the given dimension.
        Parameters:
        rng - Generator for the individual components of the vectors. A shallow copy will be stored in the sampler.
        dimension - Space dimension.
        Returns:
        the sampler
        Throws:
        java.lang.IllegalArgumentException - If dimension <= 0
        Since:
        1.4