stato 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm ruby jruby-1.7.4
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stato.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 jay
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,27 @@
1
+ # Stato
2
+
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ gem 'stato'
9
+
10
+ And then execute:
11
+
12
+ $ bundle
13
+
14
+ Or install it yourself as:
15
+
16
+ $ gem install stato
17
+
18
+ ## Usage
19
+
20
+
21
+ ## Contributing
22
+
23
+ 1. Fork it
24
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
25
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
26
+ 4. Push to the branch (`git push origin my-new-feature`)
27
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,3 @@
1
+ module Stato
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,53 @@
1
+ java_import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics
2
+
3
+ require 'rubygems'
4
+ require 'pry'
5
+
6
+ module Stats
7
+
8
+ class Compute
9
+ attr_accessor :file_name
10
+ attr_accessor :result
11
+
12
+ def initialize(params)
13
+ @result = []
14
+ @file_name = params[:file]
15
+ calculate
16
+ self
17
+ end
18
+
19
+ private
20
+ def calculate
21
+ count = 10
22
+ count.times do |index|
23
+ puts "Reading #{index}"
24
+ stats = DescriptiveStatistics.new
25
+
26
+ Object::IO::File.foreach(@file_name, :encoding => "BINARY").with_index { |line, line_number|
27
+ line = line.split(',')
28
+ stats.add_value(line[index].to_i)
29
+ count = line.length
30
+ }
31
+ evaluate(stats)
32
+ break if index.eql?(count-1)
33
+ end
34
+ end
35
+
36
+ def evaluate(stat_holder)
37
+ stats = {}
38
+ stats[:mean] = stat_holder.mean
39
+ stats[:sd] = stat_holder.standard_deviation
40
+ stats[:max] = stat_holder.max
41
+ stats[:min] = stat_holder.min
42
+ stats[:sum] = stat_holder.sum
43
+
44
+ [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 99, 100].each do |percentile|
45
+ stats["p#{percentile}".to_sym] = stat_holder.get_percentile(percentile)
46
+ end
47
+
48
+ @result << stats
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'stato/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "stato"
8
+ spec.version = Stato::VERSION
9
+ spec.authors = ["jay"]
10
+ spec.email = ["jayesh.sidhwani@gmail.com"]
11
+ spec.description = %q{Write a gem description}
12
+ spec.summary = %q{Write a gem summary}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,7 @@
1
+ require File.join(ENV["MATH_DIR"], 'commons-math3-3.2.jar')
2
+ require "stato/version"
3
+ require "stats/compute"
4
+
5
+ module Stato
6
+ # Your code goes here...
7
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stato
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - jay
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ none: false
28
+ prerelease: false
29
+ type: :development
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ none: false
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ none: false
44
+ prerelease: false
45
+ type: :development
46
+ description: Write a gem description
47
+ email:
48
+ - jayesh.sidhwani@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .rvmrc
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - lib/stato/version.rb
59
+ - lib/stats/compute.rb
60
+ - stato-0.0.1.gem
61
+ - stato.gemspec
62
+ - stato.rb
63
+ homepage: ''
64
+ licenses:
65
+ - MIT
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ none: false
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ none: false
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.24
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Write a gem summary
88
+ test_files: []