Class: EntropyFunction
- Inherits:
-
BaseFunction
- Object
- BaseFunction
- EntropyFunction
- Defined in:
- lib/scbi_cominer/classes/entropy_function.rb
Instance Attribute Summary
Attributes inherited from BaseFunction
#fft, #freq_table, #regions, #single_points, #snps, #values
Instance Method Summary collapse
Methods inherited from BaseFunction
#add_region, #calculate, #filter_regions, #graph, #graph2, #group_regions, #initialize, #purge_regions, #purge_snps, #regions_to_graph_data, #valid_region
Constructor Details
This class inherits a constructor from BaseFunction
Instance Method Details
#evaluate_pos(i) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/scbi_cominer/classes/entropy_function.rb', line 9 def evaluate_pos(i) res = 0 nseq = @freq_table.nseq(i) || 0 if nseq>0 @freq_table.frequency_table.keys.each do |k| if k!='-' freq = @freq_table.frequency_table[k][i] || 0 co = freq.to_f/nseq.to_f if (co > 0) res += ((-1*co*log2(co))); end end end end return res end |
#log2(v) ⇒ Object
5 6 7 |
# File 'lib/scbi_cominer/classes/entropy_function.rb', line 5 def log2(v) return (Math.log10(v)/Math.log10(2)) end |