Python: Creating a Gaussian distribution for a variable and running a program on a loop using the Gaussian values -


i still getting feet python , struggling solve problem:

i running script in python using toolkit named fatiando terra; define parameters of body , model gravity/gradiometry, follows:

import numpy np fatiando.vis import mpl fatiando.mesher import prism fatiando.gravmag import prism fatiando.constants import g fatiando import utils import fatiando import matplotlib.pyplot plt  model = prism(-1000, 1000, -1000, 1000, 1000, 1100, {'density': 300}) n = 500 x = np.zeros(n) y = np.zeros(n) z = np.linspace(0, 2000, n) data = np.array([prism.gx(x, y, z, [model]),                  prism.gy(x, y, z, [model]),                  prism.gz(x, y, z, [model]),                  prism.gxx(x, y, z, [model]),                  prism.gxy(x, y, z, [model]),                  prism.gxz(x, y, z, [model]),                  prism.gyy(x, y, z, [model]),                  prism.gyz(x, y, z, [model]),                  prism.gzz(x, y, z, [model])]) 

following this, plotting using python, code not relevant.

i have performed tiny gaussian array manually, using:

from numpy.random import multivariate_normal multivariate_normal([300]. [[300]], 10) 

the 10 values provided me manually entered script , generated outputs.

what trying perform gaussian distribution +-100 on density value of 300. want generate 1000 values , loop them script, running program 1000 times, once each density variant.

for output, using:

titles = ['gx', 'gy', 'gz', 'gxx', 'gxy', 'gxz', 'gyy', 'gyz', 'gzz'] np.savetxt(title, np.vstack((z.ravel(), d.ravel())).t) 

ideally, gaussian array output text in same fashion, using mean value of 1000 samples rather individual value. standard deviation great.


apologies if asking much, , massive available. cheers!

this more of extended comment answer, though may serve latter.

wrapping code in function, calling function in loop, averaging result @ end, (partly symbolic):

##import statements  ndensities = 1000  def dowork(density):     model = prism(-1000, 1000, -1000, 1000, 1000, 1100, {'density': 300})     ##other code     return data   ## or whatever important  densities = multivariate_normal([300], [[300]], ndensities) results = [] density in range(densities):     results.append(dowork(density)) results = np.vstack(results)   ## or hstack or dstack, depending on dimensions of `data` mean = results.mean()   # possibly: results.mean(axis=0) or axis=1 etc. again dependent on dimensions std = results.std() 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -