Skip to main content
1 vote
1 answer
59 views

numpy.random - size and shape confusion

I was looking through some codes and saw this line, numpy.random.normal(size=x.shape). Where, x = numpy.linspace(1, 2, 100). I don't understand what this does. I've only come across, np.random.normal(...
Govind's user avatar
  • 25
1 vote
3 answers
130 views

How can I quickly generate a (large) list of random numbers given a list of seeds as input?

I need to make a function that takes in an array of integers and returns a list of random numbers with the same length as the array. However, there is the restriction that the output random number ...
rtg142857's user avatar
2 votes
1 answer
87 views

Confusion regarding the inner workings of NumPy's SeedSequence

In case it matters at all, I'm using Python 3.11.5 64-bit on a Windows 11 Pro desktop computer with NumPy 1.26.4. In order to try to better understand what NumPy is doing behind the scenes when I ask ...
Mel's user avatar
  • 27
0 votes
1 answer
105 views

How to find if two arrays are from uncorrelated distributions?

I have two arrays - array1 and array2. How confidently can I state that they are generated from uncorrelated distributions? Just checking the correlation values would not suffice; I would require p-...
Anirban Chakraborty's user avatar
0 votes
1 answer
60 views

How to randomly map a proportion of data value to a specific category?

I have a dataset below which shows if a customer is a return customer or not. The end goal is for all returned customers, I need to map about 25% of them to 'yes 1 purchase' and 75% of them to 'yes &...
user032020's user avatar
3 votes
2 answers
674 views

Correctly seeding numpy random generator

For my scientific experiments, I usually seed using: rng = np.random.Generator(np.random.PCG64(seed)) which for the current numpy version is equivalent to rng = np.random.Generator(np.random....
saper0's user avatar
  • 374
2 votes
1 answer
635 views

Scaling of a Standard Normal Distribution

I have a question that is closely related to this one: Normed histogram y-axis larger than 1 The solution of the above thread was to scale the dimensions of the axis properly. However, that solution ...
Laulito's user avatar
  • 75
0 votes
1 answer
203 views

Why does np.random.choice take so much longer than np.random.randint?

I've been reading that np.random.choice is faster than np.random.randint (here and here), however when comparing the speed difference between import numpy as np for i in range(100000): np.random....
Trahtorco's user avatar
0 votes
1 answer
88 views

How to restore matlab random generator state into numpy?

I can save the state of matlab random generator with the following code seed = 10; rng(seed, 'twister'); %... random functions that don't need to be reproduced% s = rng; s.Type s.Seed s.State save('...
Divyansh Gupta's user avatar
0 votes
1 answer
60 views

Create Numpy array from list of arbitrary sized bites

How can I create a numpy array from a python list of bytes objects of an arbitrary (but known) size? Example: size = 10 byte_list = [np.random.default_rng().bytes(size) for i in range(100)] ...
aabceh's user avatar
  • 95
0 votes
1 answer
67 views

Can't assign the "sum of np.random.normal" in a element of array

I am trying to produce random number by random.normal and take the summary of them. Then, I tried to assgin the value to each element in the array sum. I made a zero array (float type) by np.zeros and ...
XYJ's user avatar
  • 11
0 votes
0 answers
135 views

Randomly sampling similar distributions

I want to find a robust way to sample distributions that are similar to an existing distribution. This new distribution should be at least r/2 away from the original distribution, but at most r away. ...
MATH101's user avatar
  • 23
1 vote
3 answers
923 views

Uniformity test on a large set using scipy.stats.kstest

I'm playing around with some hardware entropy creation. I'm using electronic sensors to sample the environment, using A2D with between 12-16 bits of resolution. I'm hypothesizing that the lower-order ...
cbp2's user avatar
  • 245
-1 votes
1 answer
746 views

Generate bootstrap sample from ndarray

Is there a way to generate a bootstrap sample on an N-dimensional array? I am limited to using numpy==1.19.4 I have already tried using a for loop on the other dimensions to no avail, but the ...
mj_whales's user avatar
  • 122
3 votes
1 answer
1k views

`numpy.random.normal` generates different numbers on different systems

I'm comparing the numbers generated with np.random.normal on two different systems (details see below) with the following code (I'm using the legacy np.random.seed because this is used by another ...
a_guest's user avatar
  • 36.4k

15 30 50 per page
1
2 3 4 5 6