Questions tagged [random]

This tag is for questions pertaining to random numbers, whether pseudo random or truly random.

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

How to random the questions for my quiz game in C# Console App [closed]

I create a quiz game app. The user will answer 3 subjects and it is a multiple choices. However, I am struggling to random the questions per subject. Any suggestions here? Here is my code: ...
user avatar
2 votes
2 answers
39 views

Sampling from k circles with different radii

Description: I would like to sample n_points points from k circles whose radii and centers are given as lists. Note: This is my ...
user avatar
1 vote
2 answers
63 views

Generating random integers in one of three ranges

I have a function returns a random integer number. This function only accepts these three numbers 1,2 and 3(there's another function in my code which is make sure of this otherwise that function will ...
user avatar
  • 13
8 votes
5 answers
2k views

Simple Python code that makes a random string of letters and numbers

My code basically picks random letters and numbers from three lists and makes a random combination with them. I decided to write this code just for fun, however I feel like the code can be made ...
user avatar
  • 83
3 votes
2 answers
107 views

Cryptographically secure version of the core array_rand() function

I want a cryptographically secure version of array_rand(). Is this it? ...
user avatar
5 votes
2 answers
172 views

Truth or dare program in java

I wrote this code in Java as a "Truth or Dare" game where if you type "truth" or "dare", it will pick a random number from the switch and then output the truth question ...
user avatar
3 votes
1 answer
125 views

Randomly set styles with JavaScript

I have created a function which randomly sets styles using CSS selectors. Right now it returns a random item from an array. The program also works with shorthand properties (such as ...
user avatar
5 votes
4 answers
382 views

Coin flip streaks in Python

Below is the wording from the problem in Automate the Boring Stuff book. The bold text leads me to believe that I should be checking for a streak and not multiple streaks within each experiment of 100 ...
user avatar
  • 51
-1 votes
2 answers
60 views

Quantum Random Generator outputs pieces of PI [closed]

This is a curiosity as a follow up from Purely Random Numbers Generator ...
user avatar
  • 23
0 votes
2 answers
72 views

Purely Random Numbers Generator

I think the best Random Number on the Planet is PI. I wrote a code that generates a list of pseudo-random numbers in Python. Then it treats this list as positions of digits in Pi and then outputs ...
user avatar
  • 23
3 votes
0 answers
32 views

Idiomatic PRNG in Scheme

For reasons that are too dreary to detail, I need to reproduce several pseudo random number generators in different languages. It mostly involves translating ancient C and FORTRAN code. No problems ...
user avatar
  • 195
-3 votes
1 answer
263 views

Choose a word randomly from input, without storage [closed]

It is a practice assignment (optional). The question is asking to "Write a program RandomWord.java that reads a sequence of words from standard input and prints one of those words uniformly at ...
user avatar
  • 95
8 votes
3 answers
797 views

Finding the perfect statline for a roleplaying game using Python

I made a program for fun that tries to roll a perfect statline, i.e a statline with two groups of only 18s, for a role-playing game. I'm still a newbie in python so mainly trying to learn how to make ...
user avatar
0 votes
1 answer
65 views

Python - Efficiently pick random data from an array, generate random UUIDs and save it all in an Excel table

I wrote the following prototype: ...
user avatar
  • 195
5 votes
4 answers
1k views

Get random time between two time inputs

This code takes two times as input and then calculates a random time between the two inputs. ...
user avatar
2 votes
1 answer
86 views

Robotic swarm simulation: aggregation

This program simulates the phenomenon of aggregation of a swarm of robots with no cooperation between each other and each robot following a very simple rule: The velocity of this robot has a random ...
user avatar
  • 27k
4 votes
1 answer
77 views

Let's get random, extending Python's base random class

So Python's base random class uses the Mersenne Twister as its base for seeded random number generation. If available, it can use /urandom/, but that is beside the ...
user avatar
0 votes
0 answers
61 views

C# PRNG class based on xoshiro256**

Background I'm creating a (probably bad) map-generation utility in C# to generate fractal terrain and similar. Nothing I do probably needs special treatment, but I thought it best to start with a good ...
user avatar
  • 166
2 votes
1 answer
66 views

Any issue with this as a password generator?

Was trying to create a password generator like the one Bitwarden has... Curious if anyone sees any issues with this? (wordlist shortened for readability) There perhaps there's a more efficient way I'...
user avatar
2 votes
0 answers
38 views

Python: Random forest code optimization

I've been working on random forest algorithm for classification with roulette selection to find best splits. I came up with this homebrew based on this article https://machinelearningmastery.com/...
user avatar
1 vote
0 answers
26 views

simulation of updating a dataset from real time data

In this code (reproducible example) I want to generate a dataframe composed by random dates in the first col, and by random numbers (in reality they will be generate from a socket) in the second ...
user avatar
  • 111
5 votes
1 answer
115 views

Monte-carlo simulation code - simple exercise

I created a quick monte-carlo simulation which seems to do what I want (simple version below). The code basically simulates a Poisson distribution, say this results in a simulation of ...
user avatar
  • 53
2 votes
1 answer
82 views

Generating a random ipaddress in C

I was looking to receive some feedback on the function I wrote to generate a random ip address. The code is pretty messy and just wanted some feedback regarding optimizations, memory leaks and best ...
user avatar
1 vote
2 answers
50 views

Optimal random integer function

What I have Header file: int randomInt(int start, int end); Implementation file: ...
user avatar
2 votes
1 answer
268 views

React app that uses hooks and shows a random image every two seconds

React beginner here. I'm practicing state and hooks, and I wanted to create a small app that every two seconds fetches an image URL from a service (that returns random images) and shows the returned ...
user avatar
  • 145
3 votes
1 answer
75 views

Improving performance of 'Prioritized left shuffle algorithm'

I wrote a prioritized left shuffle algorithm (the code is copied from my open source C# project Fluent Random Picker). That means: You've got some values and each of them has a priority (a number). ...
user avatar
  • 207
2 votes
1 answer
48 views

Python Library for Random Collections

I created a small library Python library to randomly create primitive types and collections. The primitive types are int, float, and string. The collections are tuples of 2, tuples of 3, a list, a 2d ...
user avatar
2 votes
0 answers
73 views

Creating a simple one-dimension Sobol sequence generator

A Sobol sequence, a series of low-discrepancy quasi-random numbers in range [0,1], can be generated by first initializing a vector of direction numbers: ...
user avatar
2 votes
0 answers
110 views

Python Markov Chain based pseudoword generator

This is a Python 3 module that generates random pronounceable word-like strings based on Markov Chains. It has many modes, each mode conforms to the structures of dictionary words to a degree, the two ...
user avatar
1 vote
1 answer
97 views

Python 3 weighted random choice function memoized version

I have written a function that randomly picks one element from a set with different probabilities for each element, anyway it takes a dictionary as argument, the keys of the dictionary are the choices ...
user avatar
7 votes
2 answers
1k views

Assign determisitic Orcish names for debugging

Orcish Large volumes of unlabelled data are hard to visualize when debugging; I find it difficult to keep track of the pointers in memory. I have used this code to assign Orcish names, (it's a name ...
user avatar
  • 1,015
-1 votes
4 answers
89 views

Python weighted choosing that works with very large numbers

I have written a function to choose randomly with weights from very large data sets in which the weight of elements can be several thousands. The input of the function is a flat ...
user avatar
1 vote
2 answers
857 views

Generate random string to match a specific pattern

...
user avatar
5 votes
2 answers
366 views

Randomized Queue with ArrayList from Princeton's Algorithm Book

In the book they recommend to utilize an Array, but I think that it's easier to use an ArrayList instead, is there any problem with that? Is this code well designed? ...
user avatar
0 votes
0 answers
36 views

Random sample items for testing

This function (in a React web application) code takes a random sample of items to test in each test function, for end-to-end testing: ...
user avatar
  • 101
2 votes
2 answers
111 views

Markov text generator program in Python

This is my first non-trivial program in my Python. I am coming from a Java background and I might have messed up or ignored some conventions. I would like to hear feedback on my code. ...
user avatar
3 votes
1 answer
481 views

Randomly place Divs on webpage and make sure they don't overlap

Currently I am working on a project for which I want to have the different links (div elements) placed randomly on my webpage. To accomplish this, I first generate a set of coordinates and later check ...
user avatar
  • 81
6 votes
1 answer
376 views

Python code for eliminating options for random intergers as they get picked

My goal is to write code that picks several random numbers from a range without repeating any previously chosen numbers. I figured out a functional solution for my problem but it seems very bulky and ...
user avatar
1 vote
1 answer
44 views

Build a fixed-length vector from a recursive factory function

I need a function of type forall (n :: Nat). RandomGen q => q -> Vec n q. Obviously this is possible to do (correctly, don't just ...
user avatar
1 vote
1 answer
135 views

A simple noise visualizer made using Pygame GUI

I was trying to make a simple noise visualizer using the noise, pygame and pygame_gui ...
user avatar
4 votes
3 answers
884 views

Python random word generator that generates a wordlike pronounceable string

This is a random word generator I wrote in Python 3 today, I don't know how many Python implemetations of this exist, but this is my first try and it is completely working. It returns a random word ...
user avatar
4 votes
2 answers
2k views

Custom UUID implementation on C++

The code's gonna be pretty simple and YES, I do know, what a proper UUID4 implementation is and what are possible approaches to implement RFC 4122. But somewhere there exists a small piece of software,...
user avatar
3 votes
1 answer
103 views

Reservoir Sampling of an enumerable collection of unknown size

I have an enumerable source for which I do not know how big it is. I want to select a random element from it, without having to hold the whole collection in memory and with uniform distribution. I ...
user avatar
  • 33
7 votes
2 answers
376 views

Convenience function wrapping C++17's std::sample for distance=1 case

C++ has the function std::sample which randomly samples from a range and places the results via an output iterator. My goal is to create a utility that directly returns a single value in the event ...
user avatar
2 votes
1 answer
41 views

convert GCCRandom(Mersenne Twister by Takuji Nishimura and Makoto Matsumoto) to stl random

I am trying to translate the book Game Coding Complete by Mike McShaffry 4E to modern C++17 standard and faced with the code of Mersenne Twister by Takuji Nishimura and Makoto Matsumoto. Is it right ...
user avatar
  • 23
4 votes
1 answer
61 views

Finding number of possible arrangements of books on a shelf with a Monte-Carlo approach

The Problem I am trying to determine numerically how many possible ways a number of books can be arranged on a shelf. Specifically, there are x3 categories "physics", "sci-fi", and ...
user avatar
  • 141
1 vote
1 answer
63 views

find leading zeros: performance

I am trying to find a N number of leading zeros from the output of the sha1 hash function. I would like N to go up to 10 or 9. Currently I can get to 7 in about 7 minutes (even though is not always ...
user avatar
  • 229
4 votes
3 answers
612 views

This code is a non-static C# class for rolling a number of dice

Hello Everyone! Fellow human beings, today I present to you my dice rolling script! Behold, in my amateurish attempt at some raw C# code. Perhaps this will remain here regardless of the dozens of ...
user avatar
  • 41
3 votes
2 answers
139 views

Catch The Rabbit Game: How to Create Non-Repeating Randomization? (JavaScript, CSS, HTML)

I've designed this game, it's my first project. It's a spin-off from "The Pig Game" in a JavaScript course. I tweaked the HTML and CSS templates of the Pig Game for the UI, but I did the ...
user avatar
2 votes
1 answer
82 views

Pseudo-random number generator & password generator

I've started learning Rust and decided to implement something on my own from scratch. I've implemented a PRNG and I use it to generate random passwords. Project tree: ...
user avatar

1
2 3 4 5
16