From cfc64a2966ab38698e499f0b44f41208ee77a07f Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 26 Apr 2016 17:38:15 +0200 Subject: first nanomaterial prediction --- lib/overwrite.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/overwrite.rb') diff --git a/lib/overwrite.rb b/lib/overwrite.rb index cef5758..4a79051 100644 --- a/lib/overwrite.rb +++ b/lib/overwrite.rb @@ -114,6 +114,15 @@ class Array Math.sqrt(self.sample_variance) end + def for_R + if self.first.is_a?(String) + #"\"#{self.collect{|v| v.sub('[','').sub(']','')}.join(" ")}\"" # quote and remove square brackets + "NA" + else + self.median + end + end + end module URI -- cgit v1.2.3 From dc4ab1f4e64d738d6c0b70f0b690a2359685080f Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 12 Oct 2016 21:32:27 +0200 Subject: physchem regression, correlation_filter for fingerprints --- lib/overwrite.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/overwrite.rb') diff --git a/lib/overwrite.rb b/lib/overwrite.rb index 4a79051..d0422ee 100644 --- a/lib/overwrite.rb +++ b/lib/overwrite.rb @@ -101,13 +101,13 @@ class Array end def mean - self.inject{ |sum, el| sum + el }.to_f / self.size + self.compact.inject{ |sum, el| sum + el }.to_f / self.compact.size end def sample_variance m = self.mean - sum = self.inject(0){|accum, i| accum +(i-m)**2 } - sum/(self.length - 1).to_f + sum = self.compact.inject(0){|accum, i| accum +(i-m)**2 } + sum/(self.compact.length - 1).to_f end def standard_deviation @@ -123,6 +123,13 @@ class Array end end + def collect_with_index + result = [] + self.each_with_index do |elt, idx| + result << yield(elt, idx) + end + result + end end module URI -- cgit v1.2.3 From 0ddd04c32280e6fd166a52fa6da653df24aabf99 Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 23 Nov 2016 15:10:58 +0000 Subject: added delog10;generalized mmol2-log10 --- lib/overwrite.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/overwrite.rb') diff --git a/lib/overwrite.rb b/lib/overwrite.rb index d0422ee..31d30c9 100644 --- a/lib/overwrite.rb +++ b/lib/overwrite.rb @@ -28,6 +28,11 @@ class Float def signif(n) Float("%.#{n}g" % self) end + + # converts -10 logarithmized values back + def delog10 + 10**(-1*self) + end end module Enumerable -- cgit v1.2.3