Questions tagged [random-seed]

A random-seed is used to initialize a pseudo-random number generator in many programming languages.

937 questions
-1
votes
1 answer

How to get Random seed given first 2 pseudo random numbers

I am looking for a function that will return a seed of C# Random class based on the first two int numbers produced by Random.Next(). I would like to avoid brute force (this is what I tried). Essentially, I am looking for a reverse function for this…
oleksii
  • 35,458
  • 16
  • 93
  • 163
-1
votes
1 answer

Even setting random seed sequential model in keras returns differnt results

Can anyone help me to understand why this model does not give reproducible results? It changes the accuracy values for test sets and other validation sets I am using, each time I run it. I am using a defined seed. I can not understand why that is…
Mauro Nogueira
  • 131
  • 2
  • 13
-1
votes
2 answers

Python seed through the subfunction

I have a function and a subfunction and in each of them some random arrays are being generated. In order to make the result reproducible, I use seed. However I see strange cases. When, I have a seed in the subfunction, the random numbers in the…
Afshin Oroojlooy
  • 1,326
  • 3
  • 21
  • 43
-1
votes
2 answers

Why does srandom(time(NULL)) behave differently within main() function and that of a user defined function?

#include #include #include void sep_gen(void); int main() { srandom((unsigned)time(NULL)); printf("Random Numbers\n"); sep_gen(); sep_gen(); sep_gen(); return(0); } void sep_gen(void) { long int r; int i; for…
Arshitha
  • 33
  • 1
  • 8
-1
votes
1 answer

Produce a random seed to give to srand() - Not time(NULL)

I am currently writing a level generation program for the game Sokoban. I use the rand() function quite a lot to generate each level, and I thought that a nice feature would be for the user to be able to control the seed used for the generation,…
Conor Watson
  • 567
  • 1
  • 7
  • 28
-1
votes
2 answers

How to improve this random number generator code in c++?

I am C++ student and I am working on creating a random number generator. Infact I should say my algorithm selects a number within a defined range. I am writing this just because of my curiosity. I am not challenging existing library functions. I…
anjanik012
  • 149
  • 3
  • 11
-2
votes
3 answers

How to mimic rand() function of C in python?

I want to convert the following C code to python : timeVar = time((time_t *)0x0) seed = (uint)timeVar; srand(seed); random_value1 = rand(); random_value2 = rand(); random_value3 = rand(); Basically, i have a seed used in the C code i provided…
bd55
  • 55
  • 7
-2
votes
1 answer

how to mitigate segmentation fault in C?

From what i heard or read, segmentation fault occurs when we try to write on read only memory or writing on unallocated memory. I searched the whole code putting a lot of printf to see where it happens and why but i got no better results. See the…
-2
votes
2 answers

Why im getting 2 different results on the same seed number?

I tried two different ways to get a coin flip result, seeding the RNG first in order to get reproducible results. First, I tried using random.randint: import random random.seed(23412) flip = random.randint(0,1) if flip == 0: …
-2
votes
2 answers

C++ random number string from seed value

This might be ridiculously easy but I'm still beginner. I would need to create a string including 5 random numbers seperated by spaces. With code below, I get e.g. random = "12345" but I need string random = "1 2 3 4 5" in the end of the code…
-2
votes
1 answer

How can I use "srand" in c++, without getting stackoverflow exception thrown?

Error message: Unhandled exception at 0x00F94619 in Cpluspluslearning.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x00CD2FC0). I am trying to make a deck of playing cards, to learn c++. Everything works fine, and I am trying to make a…
-2
votes
2 answers

Change random character in string

Good time of the day I have to implement some functions on my site. When a user enters the website, he has to enter a number of errors that should be occurred in some string. If he chooses 0, the original string will be displayed without error. If…
-2
votes
1 answer

How to set 256 bit length random number seed

For security, I need to use 256 bits input as the rand seed, but it seems there is no satisfied API or functions, for example, in Golang std library, the seed should be int64, or 64 bits integer. // Seed uses the provided seed value to initialize…
Edgar
  • 89
  • 2
  • 9
-2
votes
1 answer

random_states parameter in Machine Learning Models

I have seen ML tutorials using a parameter called random_states. Why and how this parameter can make changes in the model? from sklearn.tree import DecisionTreeRegressor melbourne_model =…
-2
votes
1 answer

Outputting randomly generated special character in java

I am trying to generate a random password that includes special characters. The generated password string will return to the main method. This is the output that I get when I use 79 as my seed: koLN59 This is the output I am supposed to get when…
LOA
  • 23
  • 3