# Random Vector/point/Position inside Sphere in Animation Nodes

Whats a good and performant way of creating a list of random vectors inside a given radius/sphere?

the random vector node (with scale set to 1) unfortunately creates vectors ranging from (-1, -1, -1) to (1, 1, 1), which results in a cube like shape. When changed to Normalized Vector, all vectors have a magnitude of exactly 1, resulting in uniform distribution on the surface of a sphere.

How can I achieve random vectors with a magnitude ranging from 0 to 1?

Is there a better way than creating a loop of a single normalized vector with a random scale?

• What about multiplying with .5 and adding 1 ? 😊 Jul 20, 2021 at 14:50
• I don't want vectors in the positive quadrant, I want vectors with a maximum but variable length. For example the vector (-1, -1, -1) has a length of 1.73 but i only want vectors in the range of 0 to 1. The Normalize Vector option in the node results in vectors of length 1 and exactly length 1. 😊 Jul 20, 2021 at 14:57

Spherical distribution of random points inside sphere the actual way: link Fast and simplified version:  • The cube root is just for a uniform distribution, right? (I actually don't need that, but nice to know, its that simple) I also like the scaling afterwards instead of using a loop, didn't think of that. Jul 20, 2021 at 18:51
• Yes cube root is for uniform distribution Jul 21, 2021 at 1:27

So seems like my first (second) idea works great and performs really well:

I use a Random Number inside a loop to control the scale of a single Random Vector node. The Random Vector is set to Normalized Vector. I also added a basic setup to have some control over the seeds.

Node Setup and comparison to the native random vector nodes: 