diff --git a/Xyz.hs b/Xyz.hs
--- a/Xyz.hs
+++ b/Xyz.hs
@@ -16,11 +16,11 @@
            , mult3x3TransposeByXyz
            ) where
 
-
 import Numeric.LinearAlgebra ( (@@>), Matrix )
 import Foreign.Storable ( Storable )
 import Data.Data ( Data )
 import Data.Typeable ( Typeable1 )
+import System.Random ( Random(..) )
 
 data Xyz a = Xyz a a a deriving (Show, Eq)
 
@@ -29,6 +29,18 @@
 
 instance Functor Xyz where
   fmap f (Xyz x y z) = Xyz (f x) (f y) (f z)
+
+instance Random a => Random (Xyz a) where
+  random g0 = (Xyz x y z, gz)
+    where
+      (x,gx) = random g0
+      (y,gy) = random gx
+      (z,gz) = random gy
+  randomR (Xyz x0 y0 z0, Xyz x1 y1 z1) g0 = (Xyz x y z, gz)
+    where
+      (x,gx) = randomR (x0,x1) g0
+      (y,gy) = randomR (y0,y1) gx
+      (z,gz) = randomR (z0,z1) gy
 
 zipWithXyz :: (a -> b -> c) -> Xyz a -> Xyz b -> Xyz c
 zipWithXyz f (Xyz x0 y0 z0) (Xyz x1 y1 z1) = Xyz (f x0 x1) (f y0 y1) (f z0 z1)
diff --git a/spatial-math.cabal b/spatial-math.cabal
--- a/spatial-math.cabal
+++ b/spatial-math.cabal
@@ -1,5 +1,5 @@
 name:                spatial-math
-version:             0.1.5
+version:             0.1.6
 synopsis:            3d math including quaternions/euler angles/dcms and utility functions
 description:         This is a port of my 'mathlib' C library: https://github.com/ghorn/mathlib
 license:             BSD3
@@ -17,7 +17,8 @@
                        Xyz
   -- other-modules:       
   build-depends:       base >= 4 && < 5,
-                       hmatrix >= 0.14 && < 0.15
+                       hmatrix >= 0.14 && < 0.15,
+                       random
 
 source-repository head
   type:     git
