-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added script to calculate the correlation integral of a large number …
…of points in an iterative and statistical fashion, documentation to follow
- Loading branch information
Jacob Perkins
committed
Jul 10, 2010
1 parent
c13ea83
commit 8465171
Showing
13 changed files
with
82 additions
and
928 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
analysis/dynamical_systems/correlation_integral/correlation_integral.pig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- | ||
-- Correlation Integral | ||
-- | ||
-- C(e) = lim N->inf (1/N^2)*SUM( H( e - distance(x_i,x_j) ) ) | ||
-- | ||
-- where H is the Heaviside step function { 0 if distance(x_i,x_j) > e, 1 if distance(x_i,x_j) < e } | ||
-- where x_i and x_j are different points on the attractor | ||
-- | ||
-- Here we take a sample n < N to calculate it for a given e (EPS) | ||
-- | ||
REGISTER /usr/local/share/pig/contrib/piggybank/java/piggybank.jar; | ||
%default ATTRACTOR 'data/points.tsv' | ||
%default SAMPLE_FRAC '0.1' -- higher precentage = better accuracy but slower and more intensive | ||
%default SAMPLE_SIZE '100' -- should be less than or equal to what is pulled out from the SAMPLE command | ||
%default EPS '0.5' -- independent variable in the correlation integral | ||
%default OUT 'data/corr_iter_00' | ||
|
||
attractor = LOAD '$ATTRACTOR' AS (x1:double, x2:double); | ||
first = SAMPLE attractor $SAMPLE_FRAC; | ||
second = SAMPLE attractor $SAMPLE_FRAC; | ||
sample_1 = LIMIT first $SAMPLE_SIZE; | ||
sample_2 = LIMIT second $SAMPLE_SIZE; | ||
crossed = CROSS sample_1, sample_2; -- careful | ||
dists = FOREACH crossed | ||
{ | ||
sq_dist = (sample_1::x1 - sample_2::x1)*(sample_1::x1 - sample_2::x1) + (sample_1::x2 - sample_2::x2)*(sample_1::x2 - sample_2::x2); | ||
GENERATE org.apache.pig.piggybank.evaluation.math.SQRT(sq_dist) AS dist; | ||
}; | ||
to_sum = FILTER dists BY dist < $EPS; | ||
grouped = GROUP to_sum ALL; | ||
corr = FOREACH grouped GENERATE (float)SIZE(to_sum)/((float)$SAMPLE_SIZE*(float)$SAMPLE_SIZE) AS corr_val, $EPS AS eps;; | ||
|
||
rmf $OUT; | ||
STORE corr INTO '$OUT'; |
18 changes: 18 additions & 0 deletions
18
analysis/dynamical_systems/correlation_integral/henon_map.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env ruby | ||
|
||
def henon_map | ||
steps = 1000000 | ||
a = 1.4 | ||
b = 0.3 | ||
x = 0.631354477 | ||
y = 0.189406343 | ||
|
||
steps.times do | ||
x_old = x | ||
x = y + 1 - a*x*x | ||
y = b*x_old | ||
puts [x,y].join("\t") + "\n" | ||
end | ||
end | ||
|
||
henon_map |
28 changes: 28 additions & 0 deletions
28
analysis/dynamical_systems/correlation_integral/iterate.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# | ||
# Pass these in via args | ||
# | ||
raise "\n\nUsage: ./iterate.rb /path/to/attractor <num_iters> /path/to/output_dir\n" unless ARGV.length == 3 | ||
attractor = ARGV[0] | ||
num_iters = ARGV[1] | ||
work_dir = ARGV[2] | ||
|
||
# | ||
# Parameters that are constant throughout the calculation | ||
# | ||
eps_min = 0.001 | ||
eps_increment = 0.025 | ||
sample_size = 5000 | ||
sample_fraction = 0.001 | ||
|
||
iter = 0 | ||
eps = eps_min | ||
num_iters.to_i.times do | ||
next_file = "corr_iter_" + iter.to_s | ||
next_dir = File.join(work_dir, next_file) | ||
system %Q{ pig -param ATTRACTOR=#{attractor} -param OUT=#{next_dir} -param EPS=#{eps} -param SAMPLE_SIZE=#{sample_size} -param SAMPLE_FRAC=#{sample_fraction} correlation_integral.pig } | ||
iter += 1 | ||
eps += eps_increment | ||
end | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.