mirror of
https://github.com/github/semantic.git
synced 2024-12-24 23:42:31 +03:00
Generate random numbers in batches.
This commit is contained in:
parent
b653534ddf
commit
afa04822dd
@ -277,7 +277,7 @@ pqGramDecorator getLabel p q = cata algebra
|
||||
|
||||
-- | Computes a unit vector of the specified dimension from a hash.
|
||||
unitVector :: Int -> Int -> Vector.Vector Double
|
||||
unitVector d hash = normalize ((`evalRand` mkQCGen hash) (sequenceA (Vector.replicate d getRandom)))
|
||||
unitVector d hash = normalize ((`evalRand` mkQCGen hash) (Vector.fromList . take d <$> getRandoms))
|
||||
where
|
||||
normalize vec = fmap (/ vmagnitude vec) vec
|
||||
vmagnitude = sqrtDouble . Vector.sum . fmap (** 2)
|
||||
|
Loading…
Reference in New Issue
Block a user