Skip to content

Instantly share code, notes, and snippets.

@pearcemc
Created October 22, 2010 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pearcemc/641076 to your computer and use it in GitHub Desktop.
Save pearcemc/641076 to your computer and use it in GitHub Desktop.
import scipy as sp
class PDimClass:
"""
A p-dimensional class, which takes a list of Normal distribution parameters,
each of which defines a dimension
"""
#a list of normal distribution parameter tuples, for N(mean, sd)
params = [(0,1), (0,1)]
def __init__(self, params=None):
if params:
self.params = params
def generate(self):
point = []
for dimension in self.params:
#the dimension value = (random number from standard normal distribution * sd) + mean
value = (sp.randn()*dimension[1]) + dimension[0]
point.append(value)
return tuple(point)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment