Questions tagged [random]

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

Filter by
Sorted by
Tagged with
3
votes
2answers
77 views

Mini guessing-game

I am a beginner programmer and I would like to improve in coding and develop my skills. That is why I am asking this question, what should I focus on improving in this code ? ...
1
vote
0answers
22 views

Randomly generating invoice IDs

As more fully detailed in my question here, I'm in the process of starting a small, local business and wanted to avoid showing sequential invoice IDs to clients, and instead generate completely random ...
1
vote
2answers
55 views

Python - Predicting the probability of 6 Heads or Tails in a row from a set sample size

I'm wondering whether there is a way to make this even more efficient or reduce the number of variables. ...
2
votes
0answers
45 views

Async generation of large buffers of random numbers on the GPU

I would like to obtain some feedback on a simple code I wrote to implement an easy and hopefully fast way to generate a large number of floats with CURAND and use them one at a time. This is achieved ...
3
votes
1answer
139 views

Test the hypothesis that the expected number of edges of a random connected graph is \$ O(n \log n) \$

Motivation The most common model for a random graph is the Erdős–Rényi model. However, it does not guarantee the connectedness of the graph. Instead, let's consider the following algorithm (in python-...
2
votes
0answers
46 views

Random generation java logic used in Nifi [closed]

I was just reviewing the source code of Nifi, see explanation and public version of the source. This got me wondering whether there are any obvious improvements here to increase the performance of the ...
0
votes
1answer
46 views

C++ Random Tree Node

I've been trying to kind of teach myself "Modern C++" the last couple of months and I just finished this interview type problem and thought it would be a good one to get some feedback on. I not ...
2
votes
2answers
55 views

Universally unique 64 bit long generator

I'm trying to make an ID generator that generates 64 bit longs. The IDs should be globally unique even between two offline machines. This is the same idea as UUID (GUID), but UUID is 128 bit long and ...
4
votes
2answers
92 views

Ising model simulation using metropolis algorithm

I am new to this community; I have tried my best to respect the policy of the community. I have written the Monte Carlo metropolis algorithm for the ising model. I want to optimize the code. I have ...
1
vote
3answers
59 views

high card game implementation

I wanted to write a simple implementation for a high card game. Basically two cards are drawn and the higher one wins. Additional rules: support for multiple decks, if same suits drawn then the ...
1
vote
1answer
65 views

Simulating a Rock, Paper, Scissors Game - Flexible

Today I learnt the basics of OOP. I have tried to apply them to this Rock-Paper-Scissors project. However I'm still a beginner, and so I feel my code can be improved. Are there any tips, trick or ...
4
votes
1answer
66 views

Simulated annealing for magic square-of-squares puzzle

I'm working on a function that takes in a NumPy array containing only mutually distinct positive square numbers. I want the function to pick an element at random, find if there is a lower positive ...
3
votes
1answer
76 views

Randomizing all class variables in constructor c++

I'm playing around with making random items and decided to implement the following structure. ...
4
votes
1answer
63 views

Random number generator utility class

I have implemented a utility class to perform various random number related task. I am looking for any feedback on design / implementation. I plan to expand the class, and so would like to correct any ...
3
votes
1answer
67 views

Von Neumann random bytes debiasing

I need to create a method to debias biased bytes from the method get_raw_bytes(length) using von Neumann debiasing method. Von ...
2
votes
1answer
75 views

Dice roller - python

I am about to graduate with my Associates degree in Math and will soon go for my bachelors. I've decided with two years of school left its best if I start learning to program. I am starting with ...
2
votes
1answer
77 views

Could anyone say if this is a reliable shuffling code?

I am trying to prove the famous "Monty Hall Paradox": The Monty Hall problem is a probability puzzle named after Monty Hall, the original host of the TV show Let’s Make a Deal. It’s a famous ...
5
votes
1answer
75 views

Dangers of increasing fishing on a fish population simulation

Setup The following code implements the algorithm described in this and this paper. The first paper describes how the evolution of a fish population can be simulated, while the second paper introdues ...
1
vote
2answers
63 views

Monte Carlo Simulation of “DNA Mutation” Game Mechanic

The game Space Station 13 (on the Paradise Station codebase) contains a DNA mechanic. Every carbon-based lifeform with DNA has 55 "blocks" that can be altered in a DNA Modifier, giving the mob ...
-2
votes
1answer
35 views

Python guessing game, lottery numbers but using def [closed]

So my task was to make a lottery function, but the instructor only provides half the code when explaining and going through my resources i was unable to find proper examples on how to complete it ...
0
votes
1answer
50 views

My first code - looking for feedback on best practices and things I should avoid doing in the future

After just learning a bit of Python I tried coding something myself. I attempted to do a game of Blackjack, which is far from perfect, and still doesn't have some rules a real game has (in my game an ...
7
votes
3answers
327 views

I made a guess the number game in Python

I just started programming a week ago. Online tutorials aren't my thing, so I decided to just start projects and learn what I need for the project. My first project is a guess the number game. The ...
4
votes
3answers
158 views

A dice roller in C

I am learning C and, for learning purposes, I implemented a dice roller. It uses arc4random(3) for random number generation, as I couldn't find something better. It works both interactively, if no ...
1
vote
0answers
59 views

Generate random letters containing a word

There is a popular game called 4 Pics 1 Word that presents to the user 4 pictures representing a common word. The word has to be typed by selecting some of the 9 random letters appearing below the ...
2
votes
1answer
125 views

Random Number Generator game

...
1
vote
4answers
104 views

Get a random member of a container

It was not obvious how to get a random member of a container. So I wrote a function to retrieve it given a generator. ...
3
votes
1answer
67 views

Generate random ids from specific numbers of auto generated unique ids

I have this class to generate unique ids and random ids from those unique ids. For the unique ids, it's a sequence of numbers between (start number = given number [start_seed]/or random number (0:...
4
votes
2answers
194 views

How to increase the efficiency of DLA algorithm?

The algorithm: Place seed at the center of the canvas. Release a random walker from the edge. Random walker sticks to the neighboring sites of the seed/previous points. Repeat N(particles) times. ...
3
votes
2answers
117 views

Pick a two different random elements from a given closed range

I wrote a function which picks a two different random elements from a closed range of ints and returns them as a tuple. I would like to take a your feedback, if the solution is a "Clever", "Best ...
23
votes
8answers
6k views

Random password generator in C

This is a simple password generator. What do you think about it? I am learning C for a while at school and at home. This just has a mix of symbols, lowercase, uppercase and numbers, with a ...
5
votes
4answers
356 views

Program in JAVA to generate random alphanumeric string

This code will generate a pseudorandom alphanumeric string of given length. I would welcome suggestions on how to make it more random. Beyond that, have I made any convention violations, Exception ...
3
votes
3answers
75 views

Random Function Bias Tester

I wanted to create a short little piece of code so that I could see the biases in the random function. ...
8
votes
3answers
762 views

Rolling dice in a method chain

I've been writing code for nearly 40 years now and am still not too old to learn and understand new things. Right now, my focus is a bit of OO with functional programming combined and C# with Linq is ...
4
votes
0answers
73 views

Estimate area of cropped circle with Monte Carlo

I looking around and not finding anything, I developed a simple function for estimating the area of a possibly cropped circle inside a frame. It uses a very basic MC implementation. It is pretty fast ...
2
votes
0answers
256 views

JavaScript random BigInt

Problem: JavaScript does not provide a random BigInt so there is a need to generate a random BigInt within a given range that is evenly distributed. Solution I have tried many algorithms with a ...
4
votes
1answer
103 views

Random password generator that ensures diversity of character types and absence of confusing characters

I wrote the following password generator, to generate a password in which each character group appears at least at once. ...
4
votes
1answer
59 views

Simple winform that randomizes images in a picturebox

I wrote this code for a simple app that gives us random images. The code works, but I feel like I'm doing something wrong. And one thing I would love to know is instead of grabbing from a folder ...
3
votes
0answers
23 views

Optimization of weightedWinner() and random() function

I have written a Lottery contract that picks winner based on the amount they contributed to the pool. I am looking if the code of weightedWinner function can be ...
10
votes
4answers
809 views

Shuffling multiple iterators in order

I have a Python function w/ specified functionality, and two proposed approaches - which do you prefer, and why? (performance, simplicity, clarity, etc) (both use ...
5
votes
2answers
661 views

Writing 1.5 million rows in a file

I am generating SQL statements (of MySQL format) and writing into a file to create 10,000 tables. Each table contains 5 columns with 1.5 million rows of data in each column. I generated these data by ...
3
votes
2answers
122 views

BiasedOptionChooser<T>: a class to do “weighted random choices”

I need to select "random" elements from a collection. Random is quoted because I must assign a weight to each element; elements with higher weights have a greater chance of being selected. To achieve ...
4
votes
2answers
108 views

Data structure that retrieves each item with a specified probability

I wanted a data structure that allowed me to set the chances of randomly returning each of it's elements. For example, suppose I have a Human class. Every Human has an attribute called eyeColor. I ...
0
votes
2answers
76 views

Random string generator that 'guesses' user inputted word [closed]

This takes a user inputted string, then tries to randomly 'guess' it. The problem is that whenever the input's length is 6 digits or more, it takes an incredibly long time to process it. Is there a ...
5
votes
4answers
840 views

Thread-safe, Convenient and Performant Random Number Generator

I need to generate a lot of pseudo-random numbers in my software. I'm trying to create a elegant (syntax-wise) and performant class that would allow me to generate such numbers and perform other ...
6
votes
4answers
3k views

Create two random teams from a list of players

The task is to create two random teams from a list of players. Given an example of players = ["John", "Mike", "Alice", "Bob"] One example random team would be: <...
1
vote
2answers
197 views

Generate random characters from ranges 0–9 and a–Z

I’m trying to generate 5 characters from the ranges 0–9 and a–Z. Is my solution optimal or did I overthink it a little? Would hardcoding a character list be more optimal? ...
4
votes
1answer
115 views

Random password generator (Java)

I wrote this program recently to generate random passwords for myself. It works well but it's been a long time since I wrote any java and am just looking on ways to clean up the code. I'm also not ...
2
votes
1answer
549 views

Java Perlin noise implementation

I've decided to code Perlin noise generator in Java. It works pretty well, I just want to know If I am doing everything right and if it is a valid implementation! PS : The ...
3
votes
1answer
73 views

Random password generator with choice of three strengths

My code works fine but I definitely have unecessary repeat code. I'd like to use functions so I don't have repeat code. I would appreciate any advise on how to make my password generator code more ...
3
votes
1answer
172 views

Random item generation system to be used in a roguelike

New to programming with the goal being to create my own roguelike. I am mostly interested right now in creating my item generation system. I want the code to create a random item that can then be used,...

1
2 3 4 5
15