A simplified version of my code, generates two objects with random states which their state are uniformly picked from a circle. The problem is checking the state of the objects return the same random point. What is the problem?
import numpy as np
def uniform_spherical_sample(dim=2,size=1):
"""returns a sample of size `size` uniformly from a hypersphere with dimension `dim`"""
a=np.random.multivariate_normal(mean=np.zeros(dim),cov=np.identity(dim),size=size)
normed_a=a/np.linalg.norm(a,axis=1)[...,None]
return normed_a
class a:
def __init__(self,state=uniform_spherical_sample()):
a.state=state
obj=a()
obj2=a()
print obj.state
print obj2.state
The output is always the same values for both objects. I have to emphasise that running the function twice gives different values.