Examples of nextFloat()

• it.unimi.dsi.fastutil.floats.FloatIterator.nextFloat()
• java.security.SecureRandom.nextFloat()
• java.util.Random.nextFloat()
Returns the next pseudorandom, uniformly distributed {@code float}value between {@code 0.0} and {@code 1.0} from this randomnumber generator's sequence.

The general contract of {@code nextFloat} is that one{@code float} value, chosen (approximately) uniformly from therange {@code 0.0f} (inclusive) to {@code 1.0f} (exclusive), ispseudorandomly generated and returned. All 224 possible {@code float} valuesof the form m x 2-24, where m is a positive integer less than 224 , are produced with (approximately) equal probability.

The method {@code nextFloat} is implemented by class {@code Random}as if by:

`  {@code}public float nextFloat()  return next(24) / ((float)(1 << 24)); }}`

The hedge "approximately" is used in the foregoing description only because the next method is only approximately an unbiased source of independently chosen bits. If it were a perfect source of randomly chosen bits, then the algorithm shown would choose {@code float}values from the stated range with perfect uniformity.

[In early versions of Java, the result was incorrectly calculated as:

`  {@code return next(30) / ((float)(1 << 30));}`
This might seem to be equivalent, if not better, but in fact it introduced a slight nonuniformity because of the bias in the rounding of floating-point numbers: it was slightly more likely that the low-order bit of the significand would be 0 than that it would be 1.] @return the next pseudorandom, uniformly distributed {@code float}value between {@code 0.0} and {@code 1.0} from thisrandom number generator's sequence
• java.util.Scanner.nextFloat()
Scans the next token of the input as a float. This method will throw `InputMismatchException` if the next token cannot be translated into a valid float value as described below. If the translation is successful, the scanner advances past the input that matched.

If the next token matches the Float regular expression defined above then the token is converted into a float value as if by removing all locale specific prefixes, group separators, and locale specific suffixes, then mapping non-ASCII digits into ASCII digits via {@link Character#digit Character.digit}, prepending a negative sign (-) if the locale specific negative prefixes and suffixes were present, and passing the resulting string to {@link Float#parseFloat Float.parseFloat}. If the token matches the localized NaN or infinity strings, then either "Nan" or "Infinity" is passed to {@link Float#parseFloat(String) Float.parseFloat} as appropriate. @return the float scanned from the input @throws InputMismatchException if the next token does not match the Float regular expression, or is out of range @throws NoSuchElementException if input is exhausted @throws IllegalStateException if this scanner is closed

• org.apache.commons.math3.random.RandomGenerator.nextFloat()
Returns the next pseudorandom, uniformly distributed `float` value between `0.0` and `1.0` from this random number generator's sequence. @return the next pseudorandom, uniformly distributed `float`value between `0.0` and `1.0` from this random number generator's sequence
• org.jamesii.core.math.random.generators.IRandom.nextFloat()
Returns a uniformly distributed {@code float} value between 0.0 (inclusive)and 1.0 (exclusive). @return A (pseudo-)random single-precision floating point value in theinterval [0, 1).
• org.terasology.utilities.random.FastRandom.nextFloat()
• prefuse.util.collections.LiteralIterator.nextFloat()
• ucar.ma2.Array.nextFloat()
Return the next float in the local iterator. Uses the local iterator, which is not thread-safe. Use getIndexIterator if you need thread-safety. @return next element as a float, same as IndexIterator.getFloatNext().

Examples of it.unimi.dsi.fastutil.floats.FloatIterator.nextFloat()

 `578579580581582583584585586587588` ```        // return a dictionary only if we actually used it         PlainValuesWriter dictionaryEncoder = new PlainValuesWriter(lastUsedDictionaryByteSize);         FloatIterator floatIterator = floatDictionaryContent.keySet().iterator();         // write only the part of the dict that we used         for (int i = 0; i < lastUsedDictionarySize; i++) {           dictionaryEncoder.writeFloat(floatIterator.nextFloat());         }         return new DictionaryPage(dictionaryEncoder.getBytes(), lastUsedDictionarySize, PLAIN_DICTIONARY);       }       return plainValuesWriter.createDictionaryPage();     } ```
View Full Code Here

Examples of java.security.SecureRandom.nextFloat()

 `7071727374757677787980` ```  */   private static String generateRandomString() {     final StringBuffer res = new StringBuffer();     final Random rnd = new SecureRandom();     for (int i = 0; i < 32; i++) {       int pos = (int) (rnd.nextFloat() * CHARS.length());       res.append(CHARS.charAt(pos));     }       return res.toString();   } ```
View Full Code Here

Examples of java.util.Random.nextFloat()

 `7778798081828384858687` ```        s.myBool = new Boolean(rand.nextBoolean());         s.myByte = new Byte((byte) rand.nextInt(Byte.MAX_VALUE));         s.myShort = new Short((short) rand.nextInt(Short.MAX_VALUE));         s.myInteger = new Integer(rand.nextInt());         s.myLong = new Long(rand.nextLong());         s.myFloat = new Float(rand.nextFloat());         s.myDouble = new Double(rand.nextDouble());         s.myBigDecimal = new BigDecimal(rand.nextDouble());         s.myString = Long.toHexString(rand.nextLong());         s.myUtilDate = new java.util.Date(rand.nextLong());         s.mySqlDate = new java.sql.Date(rand.nextLong()); ```
View Full Code Here

Examples of java.util.Random.nextFloat()

 `100101102103104105106107108109110` ```     System.out.println("Clearing the framebuffer a gazillion times...");     Random rand = new Random(System.currentTimeMillis());     for ( int i = 0; i < clears; i++ ) {       glClearColor(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 1.0f);       glClear(GL_COLOR_BUFFER_BIT);     }     GLSync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); ```
View Full Code Here

Examples of java.util.Random.nextFloat()

 `100101102103104105106107108109110` ```     System.out.println("Clearing the framebuffer a gazillion times...");     Random rand = new Random(System.currentTimeMillis());     for ( int i = 0; i < clears; i++ ) {       glClearColor(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 1.0f);       glClear(GL_COLOR_BUFFER_BIT);     }     GLSync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); ```
View Full Code Here

Examples of java.util.Random.nextFloat()

 `100101102103104105106107108109110` ```     System.out.println("Clearing the framebuffer a gazillion times...");     Random rand = new Random(System.currentTimeMillis());     for ( int i = 0; i < clears; i++ ) {       glClearColor(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 1.0f);       glClear(GL_COLOR_BUFFER_BIT);     }     GLSync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); ```
View Full Code Here

Examples of java.util.Random.nextFloat()

 `4445464748495051525354` ```            float[] orig = new float[1024];       MutableSparseFloatArray fromEmpty = new MutableSparseFloatArray(new float[1024]);       float density = 0.2f;       int idx = 0;       while (rand.nextFloat() > density) {         idx++;       }       int count = 0;       while (idx < orig.length) {         float val = rand.nextFloat(); ```
View Full Code Here

Examples of java.util.Random.nextFloat()

 `4950515253545556575859` ```      while (rand.nextFloat() > density) {         idx++;       }       int count = 0;       while (idx < orig.length) {         float val = rand.nextFloat();         orig[idx] = val;         fromEmpty.set(idx, val);         count++;         idx += 1;         while (rand.nextDouble() > density) { ```
View Full Code Here

Examples of java.util.Random.nextFloat()

 `6566676869707172737475` ```      MutableSparseFloatArray fromPartial = new MutableSparseFloatArray(copy);             // do 128 modifications       int mods = 128;       for (int i = 0; i < mods; i++) {         float val = rand.nextFloat();         idx = rand.nextInt(orig.length);         orig[idx] = val;         fromEmpty.set(idx, val);         fromPartial.set(idx, val);              } ```
View Full Code Here

Examples of java.util.Random.nextFloat()

 `979899100101102103104105106107` ```      for (int i = 0; i < 32*1024; i++) {         int idx = r.nextInt(orig.length);         if (r.nextBoolean()) {           assertTrue("orig "+orig[idx]+" not the same as arr "+arr.get(idx)+" at idx="+idx, orig[idx] == arr.get(idx));         } else {           float val = r.nextFloat();           orig[idx] = val;           arr.set(idx, val);         }       }       ```
View Full Code Here