Tabnine Logo
MersenneTwister.nextInt
Code IndexAdd Tabnine to your IDE (free)

How to use
nextInt
method
in
org.apache.commons.math3.random.MersenneTwister

Best Java code snippets using org.apache.commons.math3.random.MersenneTwister.nextInt (Showing top 12 results out of 315)

origin: opentripplanner/OpenTripPlanner

  public void randomize () {
    for (TIntObjectIterator<int[]> it = offsets.iterator(); it.hasNext();) {
      it.advance();
      int[] newVal = new int[it.value().length];

      RaptorWorkerTimetable tt = data.timetablesForPattern.get(it.key());

      for (int i = 0; i < newVal.length; i++) {
        newVal[i] = mt.nextInt(tt.headwaySecs[i]);
      }

      it.setValue(newVal);
    }

  }
}
origin: jMetal/jMetal

@Override
public int nextInt(int lowerBound, int upperBound) {
 return lowerBound + rnd.nextInt((upperBound - lowerBound) + 1) ;
}
origin: vmware/hillview

public int nextInt() { return this.myPrg.nextInt(); }
origin: vmware/hillview

public int nextInt(int range) { return this.myPrg.nextInt(range); }
origin: com.conveyal/r5

private ArrayList<Integer> generateDepartureTimesToSample (ProfileRequest request) {
  // See Owen and Jiang 2016 (unfortunately no longer available online), add between f / 2 and
  // f + f / 2, where f is the mean step.
  int randomWalkStepMean = (request.toTime - request.fromTime) / request.monteCarloDraws;
  int randomWalkStepWidthOneSided = randomWalkStepMean / 2;
  ArrayList<Integer> departureTimes = new ArrayList<>();
  for (int departureTime = request.fromTime + mersenneTwister.nextInt(randomWalkStepMean);
     departureTime < request.toTime;
     departureTime += mersenneTwister.nextInt(randomWalkStepMean) + randomWalkStepWidthOneSided) {
    departureTimes.add(departureTime);
  }
  return departureTimes;
}
origin: conveyal/r5

private ArrayList<Integer> generateDepartureTimesToSample (ProfileRequest request) {
  // See Owen and Jiang 2016 (unfortunately no longer available online), add between f / 2 and
  // f + f / 2, where f is the mean step.
  int randomWalkStepMean = (request.toTime - request.fromTime) / request.monteCarloDraws;
  int randomWalkStepWidthOneSided = randomWalkStepMean / 2;
  ArrayList<Integer> departureTimes = new ArrayList<>();
  for (int departureTime = request.fromTime + mersenneTwister.nextInt(randomWalkStepMean);
     departureTime < request.toTime;
     departureTime += mersenneTwister.nextInt(randomWalkStepMean) + randomWalkStepWidthOneSided) {
    departureTimes.add(departureTime);
  }
  return departureTimes;
}
origin: vmware/hillview

/**
 * @return the next pseudorandom Geometric with distribution parameter p. Should be more
 * efficient than using logs.
 */
public int nextGeometric(double p) {
  if (p <= 0) throw new IllegalArgumentException("parameter of Geometric Distribution must be positive");
  int value = myPrg.nextInt();
  double sample = (double) Math.abs(value) / Integer.MAX_VALUE;
  return (int) (Math.floor((Math.log(1 - sample) / Math.log(1-p) ) )) + 1;
}
origin: vmware/hillview

/**
 * Helper method that generates a List of random alphanumeric strings.
 * @param suppSize Number of strings
 * @param length Size of each string.
 */
public static List<String> randStringList(int suppSize, int length) {
  String aToZ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  MersenneTwister random = new MersenneTwister(2);
  ArrayList<String> names = new ArrayList<String>();
  for (int i = 0; i < suppSize; i++) {
    StringBuilder nextName = new StringBuilder();
    for (int j = 0; j < length; j++) {
      int index = random.nextInt(aToZ.length());
      nextName.append(aToZ.charAt(index));
    }
    names.add(nextName.toString());
  }
  return names;
}
origin: stackoverflow.com

 MersenneTwister rng = new MersenneTwister();
rng.setSeed(new int[] {1234567890});
System.out.println(rng.nextInt(Integer.MAX_VALUE)); // 1977150888
origin: com.conveyal/gtfs-lib

char[] chars = new char[length];
for (int i = 0; i < length; i++) {
  chars[i] = (char) ('a' + twister.nextInt(26));
origin: com.conveyal/r5

val[tripScheduleIndex][frequencyEntryIndex] = mt.nextInt(schedule.headwaySeconds[frequencyEntryIndex]);
remaining--;
origin: conveyal/r5

val[tripScheduleIndex][frequencyEntryIndex] = mt.nextInt(schedule.headwaySeconds[frequencyEntryIndex]);
remaining--;
org.apache.commons.math3.randomMersenneTwisternextInt

Popular methods of MersenneTwister

  • <init>
    Creates a new random number generator using an int array seed.
  • setSeed
    Reinitialize the generator as if just built with the given int array seed.The state of the generator
  • nextDouble
  • nextLong
  • clear
  • nextGaussian
  • nextBytes
  • nextBoolean

Popular in Java

  • Parsing JSON documents to java classes using gson
  • runOnUiThread (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • notifyDataSetChanged (ArrayAdapter)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now