how to generate gaussian distributed noise based on a data set including cartisian coordinates in python -


i looking script (preferably python) generate gaussian distributed noise. have 3d array including x,y , z coordinates of data set in 3d space. now, want generate gaussian noise data set. know can generate points "random.gauss(mu, sigma) function" dont know how can 3d data? have each direction? if so, @ end, how have correlate them? thankful or hint!!

thank you

your question kind of ambiguous. let's assume have nx3 array of positions in cartesian (x,y,z) coordinates, , want add error positions.

you can use numpy, , in particular numpy.random.normal(loc=0.0, scale=1.0, size=none). want generate size=(n,3) array of "errors", , add them position array.

if want isotropic errors, want ⟨|δr|²⟩ = ⟨σ²⟩ = ⟨σ_x² + σ_y² + σ_z²⟩ = 3⟨σ_1²⟩, one-dimensional variance (1/3) three-dimensional variance, in turn means scale parameter 1/sqrt(3) 3d sigma.

hence want:

noise_plus_signal = signal_in + \       numpy.random.normal(scale=sigma/numpy.sqrt(3.0), size=(n,3)) 

or, i've misunderstood question.

updates:

  • if data in spherical coordinates, it's easiest convert , cartesian , use algorithm above

  • if want different sigma each point, can multiply entire array of random variates (which, if above, same size array of points), array using rules of numpy. in particular, if array has shape (n,3), can use numpy.random.normal(scale=1,size=(n,3))*sigma_array sigma_array has size (n) each point gets own variance, (x,y,z) coordinates same variance given point.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -