Skip to content

Instantly share code, notes, and snippets.

@bobsomers
Created December 9, 2011 11:08
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 bobsomers/1451131 to your computer and use it in GitHub Desktop.
Save bobsomers/1451131 to your computer and use it in GitHub Desktop.
Biogpu example with arbitrary ranges.
import biogpu.correlation
# Pyroprints are defined as a list of lists. Each inner list is just a list of
# each dispensation value. Note that both sets of pyroprints you're comparing
# should have the same length for all their inner lists (i.e. they're all 104
# dispensations long. These are 32-bit floating point values.
# Here's a set of 3 pyroprints each with 3 dispensations.
A = [[1.0, 2.0, 3.0], # first pyroprint
[4.0, 5.0, 6.0], # second pyroprint
[7.0, 8.0, 9.0]] # etc...
# Here's a set of 4 pyroprints we're correlating against. It can be different
# number of pyroprints (i.e. the correlation matrix can be non-square) but the
# number of dispensations must match the other set of pyroprints.
B = [[0.1, 0.2, 0.3], # first pyroprint
[0.4, 0.5, 0.6], # second pyroprint
[0.7, 0.8, 0.9], # etc...
[0.10, 0.11, 0.12]]
# The ranges are defined as a list of tuples, where each tuple is (low, high).
# They catch any cell in the correlation matrix such that low <= value < high.
# Don't go crazy with the number of ranges. Each range uses 8 MB of GPU memory
# during computation, so the 11 ranges defined here require 88 MB of space on
# the GPU!
ranges = [(0.000, 1.000), # Catch all... how many in total?
(0.900, 0.950), # 90.0% -> 95.0%
(0.950, 0.955), # 95.0% -> 95.5%
(0.955, 0.960), # 95.5% -> 96.0%
(0.960, 0.965), # etc...
(0.965, 0.970),
(0.970, 0.975),
(0.975, 0.980),
(0.980, 0.985),
(0.985, 0.990),
(0.990, 1.000)]
# Run the correlation. This returns a list of values which is the number of cells
# in the correlation matrix that fell into the associated range. For example,
# buckets[3] is the number of cells that fell into the 0.955 -> 0.960 range defined
# above. It will print its progress, because it might take a while...
buckets = biogpu.correlation.pearson(A, B, ranges)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment