Skip to content
Advertisement

Tag: random

Generating N random unit vectors with their sum equal to 0 (Python)

I’d like to generate N random 3-dimensional vectors (uniformly) on the unit sphere but with the condition, that their sum is equal to 0. My attempt was to generate N/2 random unit vectors, while the other are just the same vectors with a minus sign. The problem is, as I’m trying to achieve as little correlation as possible, and my

Sample points from a hyperboloid

A hyperboloid has the formula -x^2/a^2 – y^2/b^2 + z^2/c^2 = 1. How can I generate samples from this hyperboloid in Python? (Say, with a=b=c=1.) I was thinking to pick random x and y in [0,1] and then fill in the z value that would make the formula equal 1. However this would not sample uniformly. Is there a better

Why non-linear response to random values is always positive?

I’m creating a non-linear response to a series of random values from {-1, +1} using a simple Volterra kernel: With a zero mean for a(k) values I would expect r(k) to have a zero mean as well for arbitrary w values. However, I get r(k) with an always positive mean value, while a mean for a(k) behaves as expected: is

Fill Excel cells with random numbers

I have a question about how to fill some cells in Excels with random values? For example, I have a part of the code with: Which gave me the error of: TypeError: Unsupported type <class ‘generator’> in write() How to fix it? Answer To write multiple cells, use write_row() or write_column() as shown in the docs. Also, try changing the

How does NumPy seed its random number generators if no seed is provided?

For example, suppose I call numpy.random.uniform(0, 1, 10) without calling any of the seed-related functions. NumPy must be using some default seed, but I couldn’t find it in the documentation. How does NumPy seed its random numbers when no seed is specified? Answer For NumPy’s legacy numpy.random.* functions, including numpy.random.uniform, a global RandomState object initialized with no arguments is used.

Overwriting an array in Numpy function Python

I am trying to write a numpy function that iterates with itself to update the values of its function. If for example Random_numb was equal to [50, 74, 5, 69, 50]. So the calculations would go like, 10* 50 = 500 for the first calculation, with the equation Starting_val = Starting_val * Random_numb. The Starting_Val would equal to 500 so

Advertisement