summaryrefslogtreecommitdiff
path: root/photon.py
diff options
context:
space:
mode:
authorAnthony LaTorre <telatorre@gmail.com>2011-05-18 18:29:43 -0400
committerAnthony LaTorre <telatorre@gmail.com>2011-05-18 18:29:43 -0400
commit3a0571534185505a38dc992a7e21a3eb027aae97 (patch)
treec60b21f5b6fcc803a9f59c2fcd2d70a42c148600 /photon.py
parent9306f888fea903accf827870a122a2f6f76e472e (diff)
downloadchroma-3a0571534185505a38dc992a7e21a3eb027aae97.tar.gz
chroma-3a0571534185505a38dc992a7e21a3eb027aae97.tar.bz2
chroma-3a0571534185505a38dc992a7e21a3eb027aae97.zip
added test likelihood
Diffstat (limited to 'photon.py')
-rw-r--r--photon.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/photon.py b/photon.py
index d1574ea..f8ece6a 100644
--- a/photon.py
+++ b/photon.py
@@ -1,6 +1,6 @@
import numpy as np
-def uniform_sphere(size=None):
+def uniform_sphere(size=None, dtype=np.double):
"""
Generate random points isotropically distributed across the unit sphere.
@@ -17,13 +17,13 @@ def uniform_sphere(size=None):
c = np.sqrt(1-u**2)
- points = np.empty((x.size, 3))
+ if size is None:
+ return np.array([c*np.cos(theta), c*np.sin(theta), u])
+
+ points = np.empty((size, 3), dtype)
points[:,0] = c*np.cos(theta)
points[:,1] = c*np.sin(theta)
points[:,2] = u
- if size is None:
- return points[0]
- else:
- return points
+ return points