ml_ratiosolve 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c76acec151175240892ce4280bbdb360af79d268
4
- data.tar.gz: 50e5f40213dec0644ad76c57672c031139f516a7
3
+ metadata.gz: 690cbbb17382e88e829a3ee728d173ec3fce5ed3
4
+ data.tar.gz: 6fbc77aa4726d5cb1ae06432126b2859c9880f72
5
5
  SHA512:
6
- metadata.gz: df72bc79f9019b6fd6142da383d79492dbff2157fa0ff0db22677b7c4727886f2f1dfb31b15f8df12bde9d290b542266ebb8f48be64c9335f82f36ca615fe2d7
7
- data.tar.gz: 23619b6eea6159c3535bf44f06065b7efad19e20c3b8e6a67e6ed393e8f55ead1f1ed627e7ec719e62aaabbc3cfe07a614d24d9406f3a7f2ed7b498fbd7c1801
6
+ metadata.gz: 9284a5669235b8b1d5dbb2911f00ddb14544d65e03adc93c57e699420a6c17866f54cbcb4371c4984d6cd130550c634ecf37124a52da900cbd6249bb3c950019
7
+ data.tar.gz: e887c5d6f8556f47bb85939aa9ff3bd5494a06fee8b7cda8eeb2d5167478a34347d0773513b1ae9d82a4064b8c06ac257d8a4eb6677113b68c5dcd0db59e20bd
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in ml_ratiosolve.gemspec
4
4
  gemspec
5
+ #gem 'nmatrix', path: '/home/cfuller/git/nmatrix'
data/bin/ml_ratiosolve CHANGED
@@ -13,6 +13,8 @@ opts = Trollop::options do
13
13
  opt :ci_level, "Float in the range 0-1 specifiying the level of confidence interval to calculate. E.g. 0.95 will calculate a 95% confidence interval", type: :float, default: 0.95
14
14
  opt :skip, "If some experiments are missing datapoints, specifiy which ones here. These should be specified as (0-indexed) treatment,experiment pairs, with a comma separating treatment and experiment and a colon separating successive pairs. E.g. to skip the first and second treatments in the first experiment: '0,0:1,0'", type: :string, default: ""
15
15
  opt :norm_index, "Normalize so that the mean value of the specified treatment is set to 1.", type: :integer, default: 0
16
+ opt :stdin, "Read from standard input rather than a file."
17
+ opt :quiet, "Only write the final result to standard output."
16
18
  end
17
19
 
18
20
  MLRatioSolveBin.go(opts)
@@ -49,11 +49,19 @@ require 'nmatrix'
49
49
  module MLRatioSolve
50
50
  class << self
51
51
 
52
+ #
53
+ # Set whether to use quiet mode. In quiet mode, no intermediate results
54
+ # are written to output.
55
+ # @param q [Boolean] whether to activate quiet mode
56
+ def quiet_mode(q)
57
+ @quiet_mode = q
58
+ end
59
+
52
60
  #
53
61
  # The normal probability distribution.
54
- # @param x [Numeric] The point at which to calculate the probability density
55
- # @param m [Numeric] The mean of the distribution
56
- # @param s2 [Numeric] The variance of the distribution
62
+ # @param x [Numeric] The point at which to calculate the probability density
63
+ # @param m [Numeric] The mean of the distribution
64
+ # @param s2 [Numeric] The variance of the distribution
57
65
  #
58
66
  # @return [Float] The probability density at the specified point
59
67
  def normpdf(x, m, s2)
@@ -231,6 +239,7 @@ module MLRatioSolve
231
239
  #
232
240
  # @return [void]
233
241
  def print_parameters(mu, sig2, gamma, x, iternum)
242
+ return nil if @quiet_mode
234
243
  puts "="*10
235
244
  puts "At iteration number #{iternum}:"
236
245
  puts "mu = #{mu.to_s}"
@@ -505,7 +514,7 @@ module MLRatioSolve
505
514
  end
506
515
  counter += 1
507
516
  if best[:mu] then
508
- puts "Best solution found so far:"
517
+ puts "Best solution found so far:" unless @quiet_mode
509
518
  print_parameters(best[:mu], best[:sig2], best[:gamma], x, counter)
510
519
  end
511
520
  end
@@ -553,7 +562,19 @@ module MLRatioSolve
553
562
  #
554
563
  # @return [NMatrix] an IxN nmatrix containing the experimental data
555
564
  def read_data_from_file(fn)
556
- N[*(CSV.read(fn).map{ |e| e.map{ |i| i.to_f } })]
565
+ File.open(fn) do |f|
566
+ read_data_from_io(f)
567
+ end
568
+ end
569
+
570
+ #
571
+ # Reads csv-formatted datapoints from an IO object. Data should be
572
+ # arranged with columns as independent experiments and rows as treatments.
573
+ # @param io [IO] The IO from which to read the data.
574
+ #
575
+ # @return [NMatrix] an IxN nmatrix containing the experimental data
576
+ def read_data_from_io(io)
577
+ N[*(CSV.new(io).map{ |e| e.map{ |i| i.to_f } })]
557
578
  end
558
579
  end
559
580
  end
@@ -1,3 +1,3 @@
1
1
  module MlRatiosolve
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/ml_ratiosolve.rb CHANGED
@@ -37,7 +37,17 @@ module MLRatioSolveBin
37
37
 
38
38
  MLRatioSolve.set_skip_indices(opts[:skip])
39
39
 
40
- x = MLRatioSolve.read_data_from_file(opts[:file])
40
+ x = nil
41
+
42
+ if opts[:stdin] then
43
+ x = MLRatioSolve.read_data_from_io(STDIN)
44
+ else
45
+ x = MLRatioSolve.read_data_from_file(opts[:file])
46
+ end
47
+
48
+ if opts[:quiet] then
49
+ MLRatioSolve.quiet_mode(true)
50
+ end
41
51
 
42
52
  n_gammas_to_fit = x.shape[1] - 1
43
53
 
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["cjfuller@gmail.com"]
11
11
  spec.description = %q{Methods for using maximum likelihood calculations to estimate parmeters of ratios of gaussian variates}
12
12
  spec.summary = %q{Methods for using maximum likelihood calculations to estimate parmeters of ratios of gaussian variates}
13
- spec.homepage = "https://github.com/cjfuller/ml_ratiosolve"
13
+ spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "trollop", "~> 2.0"
22
- spec.add_dependency "nmatrix", "~> 0.1"
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "rake"
25
- spec.add_development_dependency "rspec"
22
+ spec.add_dependency "nmatrix", ">= 0.1.0.rc1"
23
+ spec.add_development_dependency "bundler", "~> 1"
24
+ spec.add_development_dependency "rake", "> 0"
25
+ spec.add_development_dependency "rspec", "> 0"
26
26
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ml_ratiosolve
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin J. Fuller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-11 00:00:00.000000000 Z
11
+ date: 2014-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nmatrix
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0.1'
33
+ version: 0.1.0.rc1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0.1'
40
+ version: 0.1.0.rc1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.3'
47
+ version: '1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.3'
54
+ version: '1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Methods for using maximum likelihood calculations to estimate parmeters
@@ -89,7 +89,7 @@ executables:
89
89
  extensions: []
90
90
  extra_rdoc_files: []
91
91
  files:
92
- - .gitignore
92
+ - ".gitignore"
93
93
  - Gemfile
94
94
  - LICENSE.txt
95
95
  - README.md
@@ -102,7 +102,7 @@ files:
102
102
  - ml_ratiosolve.gemspec
103
103
  - spec/error_bootstrapping_spec.rb
104
104
  - spec/ml_ratiosolve_spec.rb
105
- homepage: https://github.com/cjfuller/ml_ratiosolve
105
+ homepage: ''
106
106
  licenses:
107
107
  - MIT
108
108
  metadata: {}
@@ -112,17 +112,17 @@ require_paths:
112
112
  - lib
113
113
  required_ruby_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - '>='
120
+ - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.0.3
125
+ rubygems_version: 2.2.1
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Methods for using maximum likelihood calculations to estimate parmeters of