### Home Classes Methods

### In Files

- lib/stella/core_ext.rb

### Parent

Object

### Methods

- ::from_json
- #deviation
- #dump
- #histogram
- #mean
- #median
- #mode
- #percentile
- #percentile_index
- #permute
- #permute!
- #random
- #sample
- #sd
- #squares
- #sum
- #to_json
- #variance

### Files

- LICENSE.txt
- TODO

### Class/Module Index

Quicksearch

- Stella
- Stella::API
- Stella::API::Unauthorized
- Stella::Asserts
- Stella::CLI
- Stella::Client
- Stella::Common
- Stella::Common::PrivacyMethods
- Stella::ET
- Stella::Engine
- Stella::Engine::Base
- Stella::Engine::Base::ClassMethods
- Stella::Engine::Checkup
- Stella::EventTemplate
- Stella::ForcedRedirect
- Stella::HTTPError
- Stella::Log
- Stella::Log::HTTP
- Stella::PageError
- Stella::RT
- Stella::RepeatRequest
- Stella::Report
- Stella::Report::Content
- Stella::Report::Content::ReportMethods
- Stella::Report::Errors
- Stella::Report::Errors::ReportMethods
- Stella::Report::Headers
- Stella::Report::Metrics
- Stella::Report::Metrics::ReportMethods
- Stella::Report::Plugin
- Stella::Report::Plugin::ClassMethods
- Stella::Report::Statuses
- Stella::Report::Statuses::ReportMethods
- Stella::RequestError
- Stella::RequestTemplate
- Stella::Session
- Stella::StringTemplate
- Stella::TP
- Stella::Testplan
- Stella::Testplan::ClassMethods
- Stella::TestplanQuit
- Stella::Testrun
- Stella::TimeoutError
- Stella::UC
- Stella::Usecase
- Stella::Usecase::ClassMethods
- Stella::UsecaseError
- Stella::UsecaseFail
- Stella::Utils
- Stella::VERSION
- Addressable
- Addressable::URI
- Time
- Time::Units
- Array
- DefaultTestplan
- Float
- Hash
- MatchData
- MetricsPack
- Numeric
- Object
- OpenStruct
- StellaBehavior
- StellaError
- String
- Symbol
- Thread

No matching classes.

# Array

### Public Class Methods

from_json(str) click to toggle source

    # File lib/stella/core_ext.rb, line 442
    def self.from_json(str)
      Yajl::Parser.parse(str, :check_utf8 => false)
    end

### Public Instance Methods

deviation() click to toggle source

    # File lib/stella/core_ext.rb, line 412
    def deviation ; Math::sqrt( self.variance ) ; end

Also aliased as: sd
dump(format) click to toggle source

    # File lib/stella/core_ext.rb, line 435
    def dump(format)
      respond_to?(:"to_#{format}") ? send(:"to_#{format}") : raise("Unknown format: #{format}")
    end

histogram() click to toggle source

    # File lib/stella/core_ext.rb, line 404
    def histogram ; self.sort.inject({}){|a,x|a[x]=a[x].to_i+1;a} ; end

mean() click to toggle source

    # File lib/stella/core_ext.rb, line 397
    def mean; self.sum.to_f/self.size ; end

median() click to toggle source

    # File lib/stella/core_ext.rb, line 398
    def median
      case self.size % 2
        when 0 then self.sort[self.size/2-1,2].mean
        when 1 then self.sort[self.size/2].to_f
      end if self.size > 0
    end

mode() click to toggle source

    # File lib/stella/core_ext.rb, line 405
    def mode
      map = self.histogram
      max = map.values.max
      map.keys.select{|x|map[x]==max}
    end

percentile(perc) click to toggle source

    # File lib/stella/core_ext.rb, line 425
    def percentile(perc)
      self.sort[percentile_index(perc)]
    end

percentile_index(perc) click to toggle source

    # File lib/stella/core_ext.rb, line 428
    def percentile_index(perc)
      (perc * self.length).ceil - 1
    end

permute() click to toggle source

    # File lib/stella/core_ext.rb, line 414
    def permute ; self.dup.permute! ; end

permute!() click to toggle source

    # File lib/stella/core_ext.rb, line 415
    def permute!
      (1...self.size).each do |i| ; j=rand(i+1)
        self[i],self[j] = self[j],self[i] if i!=j
      end;self
    end

random() click to toggle source

    # File lib/stella/core_ext.rb, line 422
    def random
      self[rand(self.size)]
    end

sample(n=1 ;) click to toggle source

    # File lib/stella/core_ext.rb, line 420
    def sample n=1 ; (0...n).collect{ self[rand(self.size)] } ; end

sd() click to toggle source
Alias for: deviation
squares() click to toggle source

    # File lib/stella/core_ext.rb, line 410
    def squares ; self.inject(0){|a,x|x.square+a} ; end

sum() click to toggle source

    # File lib/stella/core_ext.rb, line 396
    def sum ; self.inject(0){|a,x| next if x.nil? || a.nil?; x+a} ; end

to_json() click to toggle source

    # File lib/stella/core_ext.rb, line 439
    def to_json
      Yajl::Encoder.encode(self)
    end

variance() click to toggle source

    # File lib/stella/core_ext.rb, line 411
    def variance ; self.squares.to_f/self.size - self.mean.square; end

[Validate]

Generated with the Darkfish Rdoc Generator 2.