Skip to main content

All Questions

Tagged with
1 vote
1 answer
60 views

Generate n random 2D points within a valid region

I want to generate a fixed number of random-uniformly distributed xy points within a valid mask. The generated points should be continuous, i.e. can be "between pixels". I'm looking for an ...
Toni's user avatar
  • 33
0 votes
0 answers
50 views

Numba and Numpy Generator Methods & Thread Safety Documentation Clarification

The Numba documention for the Numpy Random module states: The current Numba support for Generator is not thread-safe, hence we do not recommend using Generator methods in methods with parallel ...
John Duffy's user avatar
1 vote
1 answer
57 views

In Python with numpy, how to get uniformly distributed random floats between 0 and a natural x, including both?

In Python with numpy, for a given natural number x, we'd like to get an array (say, 20×2 or whichever shape you wish) of uniformly distributed floats in the interval [0,x]. Notice that the interval is ...
AlMa1r's user avatar
  • 125
0 votes
1 answer
64 views

Does a sequence of random seeds generate a pseudo-random sequence?

Sorry for the convoluted title. Basically, my question is: can we say that the sequence produced by the following sequence() function is pseudo-random? import numpy as np def sequence(int n): x = ...
ffusco's user avatar
  • 98
2 votes
1 answer
63 views

Confusion regarding functions to generate random numbers in numpy

I am confused primarily on two points: Why are there different random number generator functions in numpy that seemingly produce the same thing? e.g. np.random.rand() vs np.random.uniform(); or np....
Meep's user avatar
  • 367
1 vote
3 answers
84 views

Efficient implementation for random sampling

If you have 4 lists A, B, C, and D that contain objects of particular length, like list A has n_a elements and all the elements are of width 1, list B has n_b elements and all the elements are of ...
Shravan Patel's user avatar
2 votes
2 answers
130 views

Can you make a random numpy.float128?

I want to make a random array of type numpy.float128s. This is not valid: import numpy as np a = np.random.random(100, dtype=np.float128) # not valid code I could do a = np.random.random(100).astype(...
Simd's user avatar
  • 20.9k
0 votes
1 answer
71 views

generating random numbers with numpy using multiprocessing

I want to generate random numbers in Numpy using Multiprocessing. Using this this answer I wrote the code at the end of this message, and it seems to work. Because answer I linked to is quite old, I ...
NNN's user avatar
  • 573
1 vote
0 answers
56 views

Ensure same seed generates same random numbers when using numpy and cupy

I import numpy or cupy as follows: import numpy as np # import cupy as np Then I generate X as follows: np.random.seed(0) X = np.random.rand(4, 3) I get two very different matrices depending on ...
Atharva's user avatar
  • 181
0 votes
1 answer
40 views

sample using negated normal via numpy

I have a sorted list that I need to sample from. I want to favor the items towards each end of the list. In other words, I want to sample from the list using a negated normal function such that the ...
Brannon's user avatar
  • 5,398
3 votes
2 answers
76 views

Understanding the role of `shuffle` in np.random.Generator.choice()

From the documentation for numpy's random.Generator.choice function, one of the arguments is shuffle, which defaults to True. The documentation states: shuffle bool, optional Whether the sample is ...
Joel's user avatar
  • 23.5k
1 vote
1 answer
53 views

Matching numpy rand ndarrays with MATLAB

I'm trying to match randomly generated ndarrays from numpy with MATLAB. import numpy as np # Set the seed for NumPy's random generator np.random.seed(42) #Mersenne Twister is default # Generate ...
Naveen's user avatar
  • 469
0 votes
0 answers
43 views

How to find the source code of the Algorithm for random number generation in NumPy?

like in the title, I'm searching for the exact location of source code for e.g. numpy.random.normal. I would like to know for this and some other distributions whether the random numbers are created ...
user23209914's user avatar
0 votes
1 answer
62 views

Producing filtered random samples which can be replicated using the same seed

I have $10$ random variables $X_1, X_2, \ldots X_{10} \sim \mathcal{N(0,1)}$, I want to generate $5000$ samples for them such that $X_1 < a$ and $X_i > a \forall i \in {2, 3, \ldots, 10}$. The ...
junfan02's user avatar
  • 161
3 votes
2 answers
41 views

Randomly Select Columns to Shuffle of a Two-Dimensional Dataframe

I would like to randomly select a few columns of a 2 dimensional dataframe, and shuffle the values within those columns. I can easily shuffle all values (column-wise) of the dataframe, but I am ...
user23487612's user avatar

15 30 50 per page
1
2 3 4 5
84