logo
down
shadow

How to deterministically map sequential integers to uniformly distributed doubles


How to deterministically map sequential integers to uniformly distributed doubles

By : Asep Saepuloh
Date : October 23 2020, 08:10 PM
around this issue Sure, you could use Linear Congruential Generator to do the mapping. Basically, LCG with proper parameters satisfying Hull–Dobell Theorem, uniquely maps any integer in [0...264) range into another one in the [0...264) range, good bits chopper so to speak. Doubles won't be unique, not enough of them in the [0...1) range.
Java pseudocode (sorry, did Java long time ago, assumed Java 8 with Long here)
code :
static final long a = Long.parseUnsignedLong("2862933555777941757"); // values taken from https://nuclear.llnl.gov/CNP/rng/rngman/node4.html
static final long c = Long.parseUnsignedLong("3037000493");

double mapToDouble(final int i) {
    long seed = (long)i;
    long mapl = a * seed + c; // should do wraparound automatically, or use Long.remainderUnsigned
    double x  = (x >>> 11) * 0x1.0p-53; // see http://xoshiro.di.unimi.it/
    return x;
}


Share : facebook icon twitter icon
What's the standard way for getting uniformly distributed random integers in C++?

What's the standard way for getting uniformly distributed random integers in C++?


By : Jake123
Date : March 29 2020, 07:55 AM
it should still fix some issue Boost provides many tools for random number generation. For uniform distributions you have this one:
http://www.boost.org/doc/libs/1_49_0/doc/html/boost/random/uniform_real_distribution.html
code :
#include <random>
#include <iostream>
int main()
{
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution<> dis(1, 6);
    for(int n=0; n<10; ++n)
        std::cout << dis(gen) << ' ';
    std::cout << '\n';
}
How to make a regression line in R using a normally distributed error and a uniformly distributed random variable

How to make a regression line in R using a normally distributed error and a uniformly distributed random variable


By : user3261295
Date : March 29 2020, 07:55 AM
wish of those help Arithmetic operators in R work on vectors, so you don't need the loops at all:
code :
y <- 5 + 3 * xvals + evals
xvals <- runif(n = 100, min = -1, max = 1)
evals <- rnorm(n = 100, mean = 0, sd = 1)
y <- 5 + 3 * xvals + evals

print(y)
plot(xvals, y)
y <- append(y, 5 + 3*x + e)
A space efficient data structure to store and look-up through a large set of (uniformly distributed) Integers

A space efficient data structure to store and look-up through a large set of (uniformly distributed) Integers


By : Tuciiii
Date : March 29 2020, 07:55 AM
hope this fix your issue While Jon Skeet's answer gives good savings for a small investment, I think you can do better. Since your numbers are fairly even distributed, you can use an interpolating search for faster lookups (roughly O(log log N) instead of O(log N)). For a million items, you can probably plan on around 4 comparisons instead of around 20.
If you want to do just a little more work to cut the memory (roughly) in half again, you could build it as a two-level lookup table, basically a sort of simple version of a trie.
How to get pseudo-random uniformly distributed integers in C good enough for statistical simulation?

How to get pseudo-random uniformly distributed integers in C good enough for statistical simulation?


By : mcz
Date : March 29 2020, 07:55 AM
Does that help rand % N does not work; it skews your results unless RAND_MAX + 1 is a multiple of N.
A correct approach is to figure out the largest multiple of N that's smaller than RAND_MAX, and then generate random numbers until it's less than that value. Only then should you do the modulo operation. This gives you a worst-case rejection ratio of 50%.
Uniformly distributed pseudorandom integers inside CUDA kernel

Uniformly distributed pseudorandom integers inside CUDA kernel


By : user4918081
Date : March 29 2020, 07:55 AM
With these it helps I suggest two options within a Kernel:
1) using curand_uniform to obtain a random floating point number from a uniform distribution, then map it to integer interval:
Related Posts Related Posts :
  • SpringBoot : No matching bean found exception
  • Implementing the Clonable interface, but don't have to override the clone() method
  • how can i get this code to choose a random word once from each array to print a sentence?
  • Static class to get connections from connection pool
  • Unable to start Chrome browser with user profile in Selenium
  • How to pass a object to be created as a parameter for a method in Java?
  • How to retry with hystrix
  • Loading key to KeyStore fails on Android Oreo
  • Spring+Velocity unsuccessful attempts to save object
  • Private constructor in Kotlin
  • Jetty:run fails with NoSuchMethodError with Spring 5
  • Cannot upload my Web Applicartion in Jboss7 EAP7 EAP
  • How to load a certificate from "Credential storage"?
  • Call Genexus procedure stub in Java environment
  • JavaFX clipping produces a 'lottery scratch ticket'-Effect
  • Using DateTimeFormatter on january first cause an invalid year value
  • Get all the output from Watson conversation using java
  • Java unable to open main class and jar file
  • How to override @override method from activity into another class
  • Adding Runtime VM parameters to intellij for Java 9
  • Java IBM MQ Client connected but not getting messages from queue
  • Questions of Tomcat SSL configuration
  • Stale JNLP files for <extension> (since Java 9?)
  • Properly set (system) properties in JUnit 5
  • Spring MVC Model within POST Method is empty
  • VSTS buildagent: Java 9
  • java.lang.NumberFormatException: For input string: "id" for Hibernate
  • Query id return type
  • Pass variable in API url in java .
  • Reading semicolon delimited csv
  • Get the workspace root
  • Native mmap error
  • hashmap and multiple txt files java
  • Kotlin: Access nested enum class from java
  • Google RateLimiter not Working for counter
  • Spring Boot Application Hanging When Running on Command Line
  • large amount of if else refactor
  • Unable to add xmlunit as dependancy in my pom
  • Scanner input needed twice, when only wanted once
  • How to interpret and translate kotlin code to java?
  • Firebase authentication: signInWithEmailAndPassword method dont respond at all
  • How Remove Recycler Separator/divider programmatically or using xml property
  • Not Able to Save Data Hibernate
  • Toolbar addView not working
  • Freeing memory wrapped with NewDirectByteBuffer
  • Synchronization with implicitwait() do not work, why?
  • Wrapper around Java primitive types
  • ClassNotFoundException: spark.Request when running from command line
  • Exception in Hibernate Configuration
  • How can I validate XML embedded in JSON using Citrus framework?
  • How is the String value passed to the updateText() method?
  • Memory efficient replace functions
  • Upload Photo with onActivityResult, but without Fullscreen capturing
  • Docker: Java 8 installation failing on Ubuntu
  • Java Netbeans Calculator performing wrong calculation
  • Nifi: Threads in nifi
  • While loop Int return inside the method completely dead
  • Checking if a user's entry is an integer using try catch statements
  • Forcing a subclass to provide an initialization method
  • calling a fuction and variables from another class in java
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org