Class DPopulation

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int myId
      The id of this object
      protected java.lang.String myName
      Holds the name of the statistic for reporting purposes.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void advanceToNextSubstream()
      Positions the RNG at the beginning of its next substream
      double get​(int index)
      Returns the value at the supplied index
      boolean getAntitheticOption()  
      Controls getControls()
      Returns a valid instance of Controls that can be used with this ControllableIfc or null
      int getId()  
      java.lang.String getName()
      Gets the name.
      double[] getParameters()
      Gets the parameters
      double[] getPermutation()
      Creates a new array that contains a random permutation of the population
      protected int getRandomIndex()
      Returns a random index into the population (assuming elements numbered starting at zero)
      RNStreamIfc getRandomNumberStream()  
      double[] getSampleWithoutReplacement​(int sampleSize)
      Creates a new array that contains a randomly sampled values without replacement from the existing population.
      double getValue()
      Returns a randomly selected element from the population.
      DPopulation newInstance()
      Returns a new instance of the random source with the same parameters but an independent generator
      DPopulation newInstance​(RNStreamIfc stream)
      Returns a new instance of the random source with the same parameters but an independent generator
      void permute()
      Causes the population to form a new permutation, The ordering of the elements in the population will be changed.
      void resetStartStream()
      The resetStartStream method will position the RNG at the beginning of its stream.
      void resetStartSubstream()
      Resets the position of the RNG at the start of the current substream
      double sample()  
      void set​(int index, double value)
      Sets the element at the supplied index to the supplied value
      void setAntitheticOption​(boolean flag)
      Tells the stream to start producing antithetic variates
      void setControls​(Controls controls)
      Takes in a valid instance of Controls for this class If controls is null or if it was not created by this class this method should throw an IllegalArgumentException
      protected void setId()  
      void setName​(java.lang.String str)
      Sets the name
      void setParameters​(double[] elements)
      Sets the parameters
      void setRandomNumberStream​(RNStreamIfc stream)
      Sets the underlying random number stream
      int size()
      Returns the number of elements in the population
      java.lang.String toString()  
      static java.lang.String toString​(double[] x)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • myId

        protected int myId
        The id of this object
      • myName

        protected java.lang.String myName
        Holds the name of the statistic for reporting purposes.
    • Constructor Detail

      • DPopulation

        public DPopulation​(double[] elements)
        Parameters:
        elements - the elements to sample from
      • DPopulation

        public DPopulation​(double[] elements,
                           RNStreamIfc stream)
        Parameters:
        elements - the elements to sample from
        stream - the stream to use for sampling
      • DPopulation

        public DPopulation​(double[] elements,
                           RNStreamIfc stream,
                           java.lang.String name)
        Parameters:
        elements - the elements to sample from
        stream - the stream to use for sampling
        name - the name of the population, optional
    • Method Detail

      • getName

        public final java.lang.String getName()
        Gets the name.
        Specified by:
        getName in interface GetNameIfc
        Returns:
        The name of object.
      • setName

        public final void setName​(java.lang.String str)
        Sets the name
        Parameters:
        str - The name as a string.
      • getId

        public final int getId()
        Specified by:
        getId in interface IdentityIfc
        Returns:
        Returns the id
      • newInstance

        public final DPopulation newInstance()
        Returns a new instance of the random source with the same parameters but an independent generator
        Specified by:
        newInstance in interface NewInstanceIfc<DPopulation>
        Returns:
        Returns a new instance of the population with the same parameters but a different random stream
      • newInstance

        public final DPopulation newInstance​(RNStreamIfc stream)
        Returns a new instance of the random source with the same parameters but an independent generator
        Parameters:
        stream - a random number stream, must not null.
        Returns:
        Returns a new instance of the population with the same parameters but a different random stream
      • getSampleWithoutReplacement

        public final double[] getSampleWithoutReplacement​(int sampleSize)
        Creates a new array that contains a randomly sampled values without replacement from the existing population.
        Parameters:
        sampleSize - the number to sample
        Returns:
        the sampled array
      • getPermutation

        public final double[] getPermutation()
        Creates a new array that contains a random permutation of the population
        Returns:
        a new array that contains a random permutation of the population
      • permute

        public final void permute()
        Causes the population to form a new permutation, The ordering of the elements in the population will be changed.
      • get

        public final double get​(int index)
        Returns the value at the supplied index
        Parameters:
        index - must be > 0 and less than size() - 1
        Returns:
        the value at the supplied index
      • set

        public final void set​(int index,
                              double value)
        Sets the element at the supplied index to the supplied value
        Parameters:
        index - an index into the array
        value - the value to set
      • size

        public final int size()
        Returns the number of elements in the population
        Returns:
        the size of the population
      • getParameters

        public double[] getParameters()
        Description copied from interface: ParametersIfc
        Gets the parameters
        Specified by:
        getParameters in interface ParametersIfc
        Returns:
        Gets a copy of the population array, in its current state
      • setParameters

        public final void setParameters​(double[] elements)
        Description copied from interface: ParametersIfc
        Sets the parameters
        Specified by:
        setParameters in interface ParametersIfc
        Parameters:
        elements - Copies the values from the supplied array to the population array
      • getControls

        public Controls getControls()
        Description copied from interface: ControllableIfc
        Returns a valid instance of Controls that can be used with this ControllableIfc or null
        Specified by:
        getControls in interface ControllableIfc
        Returns:
      • setControls

        public void setControls​(Controls controls)
        Description copied from interface: ControllableIfc
        Takes in a valid instance of Controls for this class If controls is null or if it was not created by this class this method should throw an IllegalArgumentException
        Specified by:
        setControls in interface ControllableIfc
      • getValue

        public final double getValue()
        Returns a randomly selected element from the population. All elements are equally likely.
        Specified by:
        getValue in interface GetValueIfc
        Returns:
        the randomly selected element
      • sample

        public final double sample()
        Specified by:
        sample in interface SampleIfc
        Returns:
        generates a random value
      • getRandomIndex

        protected final int getRandomIndex()
        Returns a random index into the population (assuming elements numbered starting at zero)
        Returns:
        a random index
      • resetStartStream

        public final void resetStartStream()
        Description copied from interface: RNStreamControlIfc
        The resetStartStream method will position the RNG at the beginning of its stream. This is the same location in the stream as assigned when the RNG was created and initialized.
        Specified by:
        resetStartStream in interface RNStreamControlIfc
      • setAntitheticOption

        public final void setAntitheticOption​(boolean flag)
        Description copied from interface: RNStreamControlIfc
        Tells the stream to start producing antithetic variates
        Specified by:
        setAntitheticOption in interface RNStreamControlIfc
        Parameters:
        flag - true means that it produces antithetic variates.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toString

        public static java.lang.String toString​(double[] x)
      • setId

        protected final void setId()