This is a java program generate pseudo-random numbers using Naor-Reingold Pseudo-Random function. Let p and l be prime numbers with l |p-1. Select an element g in Fp of multiplicative order l. Then for each n-dimensional vector a = (a1, …, an). Fa(x) = g^(a1^x1 * a2^x2 …).
Here is the source code of the Java Program to Implement Naor-Reingold Pseudo Random Function. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
//This is a java program to generate a random numbers using Naor-Reingold Psedurandom Function
import java.util.Random;
public class Naor_Reingold
{
public static void main(String args[])
{
int p=7, l=3, g=2, n=4, x;
int []a = {1,2,2,1};
int []bin = new int[4];
Random random = new Random();
System.out.println("The Random numbers are: ");
for(int i=0; i<10; i++)
{
x = random.nextInt(17);
for(int j=3; j>=0; j--)
{
bin[j] = x%2;
x/=2;
}
int mul = 1;
for(int k=0; k<4; k++)
mul *= Math.pow(a[k], bin[k]);
System.out.println(Math.pow(g, mul));
}
}
}
Output:
$ javac Naor_Reingold.java $ java Naor_Reingold The Random numbers are: 2.0 4.0 2.0 2.0 2.0 16.0 4.0 16.0 16.0 4.0
Related posts:
Guide to CopyOnWriteArrayList
Spring MVC Tutorial
Serverless Functions with Spring Cloud Function
Java Program to Find the Vertex Connectivity of a Graph
Java Program to Find the Shortest Path from Source Vertex to All Other Vertices in Linear Time
Batch Processing with Spring Cloud Data Flow
Java Program to Implement ScapeGoat Tree
Java Streams vs Vavr Streams
Java Program to Implement String Matching Using Vectors
Guide to the Volatile Keyword in Java
Spring Boot - Introduction
Java Program to Implement Euler Circuit Problem
Java Program to Implement Heap’s Algorithm for Permutation of N Numbers
Tiêu chuẩn coding trong Java (Coding Standards)
How to Get All Dates Between Two Dates?
Giới thiệu Google Guice – Injection, Scope
A Guide to EnumMap
Java Program to Perform Inorder Non-Recursive Traversal of a Given Binary Tree
Java Program to Implement the Hill Cypher
Immutable Objects in Java
Tránh lỗi ConcurrentModificationException trong Java như thế nào?
Java Program to Implement Caesar Cypher
Java Program to Find Median of Elements where Elements are Stored in 2 Different Arrays
So sánh ArrayList và Vector trong Java
A Guide to the ResourceBundle
Tips for dealing with HTTP-related problems
Java Program to Implement Sorted Array
Spring REST with a Zuul Proxy
Java – Try with Resources
Java Program to Generate Random Numbers Using Probability Distribution Function
Spring Boot - Apache Kafka
Consuming RESTful Web Services