Class: PlotStatistics::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/plot_statistics/output.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Output

Returns a new instance of Output.



5
6
7
8
# File 'lib/plot_statistics/output.rb', line 5

def initialize(params={})
  @clam_plot = params[:clam_plot]
  @monte_carlo = params[:monte_carlo]
end

Instance Attribute Details

#clam_plotObject

Returns the value of attribute clam_plot.



3
4
5
# File 'lib/plot_statistics/output.rb', line 3

def clam_plot
  @clam_plot
end

#monte_carloObject

Returns the value of attribute monte_carlo.



3
4
5
# File 'lib/plot_statistics/output.rb', line 3

def monte_carlo
  @monte_carlo
end

Instance Method Details

#to_bivariate_file(filename) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/plot_statistics/output.rb', line 27

def to_bivariate_file(filename)
  FasterCSV.open(filename, 'w') do |csv|
    csv << [
      'Radius', 'Live K(t)', 'Dead K(t)', 'L(t)',
      'Mean Live K(t)', 'Mean Dead K(t)', 'Mean L(t)', 'Upper Live K(t)', 'Lower Live K(t)',
      'Upper Dead K(t)', 'Lower Dead K(t)', 'Upper L(t)', 'Lower L(t)'
    ]

    (0...ClamPlot::MAX_RADIUS).each do |position|
      radius = position + 1
      csv << [
        radius,
        clam_plot.stats.k_ts[position],                    clam_plot.stats.dead_k_ts[position],
        clam_plot.stats.l_ts[position],
        monte_carlo.stats.mean.k_ts[position],             monte_carlo.stats.mean.dead_k_ts[position],
        monte_carlo.stats.mean.l_ts[position],
        monte_carlo.stats.upper_limit.k_ts[position],      monte_carlo.stats.lower_limit.k_ts[position],
        monte_carlo.stats.upper_limit.dead_k_ts[position], monte_carlo.stats.lower_limit.dead_k_ts[position],
        monte_carlo.stats.upper_limit.l_ts[position],      monte_carlo.stats.lower_limit.l_ts[position]
      ]
    end
  end
end

#to_univariate_file(filename) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/plot_statistics/output.rb', line 10

def to_univariate_file(filename)
  FasterCSV.open(filename, 'w') do |csv|
    csv << ['Radius', 'K(t)', 'L(t)', 'Mean K(t)', 'Mean L(t)', 'Upper K(t)', 'Lower K(t)', 'Upper L(t)', 'Lower L(t)']

    (0...ClamPlot::MAX_RADIUS).each do |position|
      radius = position + 1
      csv << [
        radius,
        clam_plot.stats.k_ts[position],               clam_plot.stats.l_ts[position],
        monte_carlo.stats.mean.k_ts[position],        monte_carlo.stats.mean.l_ts[position],
        monte_carlo.stats.upper_limit.k_ts[position], monte_carlo.stats.lower_limit.k_ts[position],
        monte_carlo.stats.upper_limit.l_ts[position], monte_carlo.stats.lower_limit.l_ts[position]
      ]
    end
  end
end