Your question is kind of ambiguous. But let's assume that what you have is an Nx3
array of positions in cartesian (x,y,z) coordinates, and you want to add an error to those positions.
You can use numpy, and in particular numpy.random.normal(loc=0.0, scale=1.0, size=None)
. You want to generate a size=(n,3)
array of "errors", and add them to your position array.
If you want isotropic errors, then you want ⟨|δr|²⟩ = ⟨σ²⟩ = ⟨σ_x² + σ_y² + σ_z²⟩ = 3⟨σ_1²⟩, so the one-dimensional variance is (1/3) the three-dimensional variance, which in turn means that the scale parameter is 1/sqrt(3) the 3D sigma.
Hence you want:
noise_plus_signal = signal_in + \
numpy.random.normal(scale=sigma/numpy.sqrt(3.0), size=(n,3))
Or, I've completely misunderstood your question.
Updates:
if the data are in spherical coordinates, it's probably easiest to convert to and from cartesian and use the algorithm as above
if you want a different sigma for each point, you can multiply the entire array of random variates (which, if you do it as above, is the same size as your array of points), by another array using the rules of numpy. In particular, if your array has shape (n,3), you can use
numpy.random.normal(scale=1,size=(n,3))*sigma_array
wheresigma_array
has size(n)
so that each point gets its own variance, but the(x,y,z)
coordinates all get the same variance for a given point.