logisticmap 0.0.3
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.
- checksums.yaml +7 -0
- data/lib/logisticmap.rb +48 -0
- metadata +49 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: b0116ce6045ad8d7cd9d201b1012b0ec7b08837a9e56a74389b01c3652b0f1cb
         | 
| 4 | 
            +
              data.tar.gz: f372ddcf940151e7fc382d5461b86c6aa04586aeda32ed31df7b9c94f025f741
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 83207eba4c8588cdcedca238ecc042b6535648019ff9cf23bfafcaa08fbea3beac2d39769db526079cbba39090869fcc95b5c1b8bb9b98a45f84874db13d8ff7
         | 
| 7 | 
            +
              data.tar.gz: f3fd7bad91d0c30aded495731272b194730459a226d55ec0d6d72fd6da2f48df8d8151b7d5c5fe922b6fb0dbe7391e8895652c0c06bf9f93500997f416770d06
         | 
    
        data/lib/logisticmap.rb
    ADDED
    
    | @@ -0,0 +1,48 @@ | |
| 1 | 
            +
            module LogisticMap
         | 
| 2 | 
            +
              require 'bigdecimal'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              # basic Logistic map
         | 
| 5 | 
            +
              def self.logistic_map(x0, r, rounding)
         | 
| 6 | 
            +
                case x0
         | 
| 7 | 
            +
                  when BigDecimal
         | 
| 8 | 
            +
                    Enumerator.new do |yielder|
         | 
| 9 | 
            +
                      number = BigDecimal("#{x0}")
         | 
| 10 | 
            +
                      o = BigDecimal("#{r}")
         | 
| 11 | 
            +
                      loop do
         | 
| 12 | 
            +
                        #precalc = number.mult(multiplier, rounding)
         | 
| 13 | 
            +
                        yielder.yield(number.round(rounding))
         | 
| 14 | 
            +
                        number = o.mult(number * (1 - number), rounding)
         | 
| 15 | 
            +
                      end
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
                else
         | 
| 18 | 
            +
                  Enumerator.new do |yielder|
         | 
| 19 | 
            +
                    number = x0
         | 
| 20 | 
            +
                    o = r
         | 
| 21 | 
            +
                    loop do
         | 
| 22 | 
            +
                      #precalc = number*multiplier
         | 
| 23 | 
            +
                      yielder.yield(number)
         | 
| 24 | 
            +
                      number = o * number * (1 - number)
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              # should be refactored into an Enumerator later, now it returns the whole array
         | 
| 31 | 
            +
              def self.logistic_points(x0_start, x0_end, x0_step, r, nth_iteration)
         | 
| 32 | 
            +
                raise(ArgumentError, "Stepping value cannot be negative!") if x0_step < 0
         | 
| 33 | 
            +
                raise(ArgumentError, "Iteration counter cannot be zero or negative!") if nth_iteration <= 0
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                x0_current = x0_start
         | 
| 36 | 
            +
                result_array = []
         | 
| 37 | 
            +
                while x0_current < x0_end do
         | 
| 38 | 
            +
                  lm = logistic_map(x0_current, r, 16)
         | 
| 39 | 
            +
                  (nth_iteration-1).times {lm.next} # skipping first values
         | 
| 40 | 
            +
                  result_array << lm.next.round(15) # return the Nth iteration
         | 
| 41 | 
            +
                  x0_current += x0_step
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
                result_array
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
             | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: logisticmap
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.3
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Földes László
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2012-08-26 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies: []
         | 
| 13 | 
            +
            description: 'This gem implements: 1.) a logistic map function (#logistic_map), which
         | 
| 14 | 
            +
              is a discrete, non-linear, dynamic equation which can show - with proper parameters
         | 
| 15 | 
            +
              - chaotic behaviour with super-sensitivity to the initial parameters. Very small
         | 
| 16 | 
            +
              changes to initial parameters cause huge changes in the result (can be used as a
         | 
| 17 | 
            +
              PRNG as iterated over and over); 2.) A tent-map version of the logistic map (#logistic_points)
         | 
| 18 | 
            +
              which returns an array of Nth iterated values of several logistic maps with their
         | 
| 19 | 
            +
              initial X0 parameter ranging from 0 to 1 by user defined steps, showing curve-like
         | 
| 20 | 
            +
              properties when plotted.'
         | 
| 21 | 
            +
            email: foldes.laszlo2@gmail.com
         | 
| 22 | 
            +
            executables: []
         | 
| 23 | 
            +
            extensions: []
         | 
| 24 | 
            +
            extra_rdoc_files: []
         | 
| 25 | 
            +
            files:
         | 
| 26 | 
            +
            - lib/logisticmap.rb
         | 
| 27 | 
            +
            homepage: https://neatpicks.wordpress.com
         | 
| 28 | 
            +
            licenses: []
         | 
| 29 | 
            +
            metadata: {}
         | 
| 30 | 
            +
            post_install_message: 
         | 
| 31 | 
            +
            rdoc_options: []
         | 
| 32 | 
            +
            require_paths:
         | 
| 33 | 
            +
            - lib
         | 
| 34 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 35 | 
            +
              requirements:
         | 
| 36 | 
            +
              - - ">="
         | 
| 37 | 
            +
                - !ruby/object:Gem::Version
         | 
| 38 | 
            +
                  version: '0'
         | 
| 39 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 40 | 
            +
              requirements:
         | 
| 41 | 
            +
              - - ">="
         | 
| 42 | 
            +
                - !ruby/object:Gem::Version
         | 
| 43 | 
            +
                  version: '0'
         | 
| 44 | 
            +
            requirements: []
         | 
| 45 | 
            +
            rubygems_version: 3.0.8
         | 
| 46 | 
            +
            signing_key: 
         | 
| 47 | 
            +
            specification_version: 4
         | 
| 48 | 
            +
            summary: Logistic family functions
         | 
| 49 | 
            +
            test_files: []
         |