Module: Quant::Mixins::FisherTransform
- Defined in:
- lib/quant/mixins/fisher_transform.rb
Overview
Fisher Transforms • Price is not a Gaussian (Bell Curve) distribution, even though many technical analysis formulas
falsely assume that it is. Bell Curve tails are missing.
– If $10 stock were Gaussian, it could go up or down $20 – Standard deviation based indicators like Bollinger Bands
and zScore make the Gaussian assumption error
• TheFisher Transform converts almost any probability distribution in a Gaussian-like one
– Expands the distribution and creates tails
• The Inverse Fisher Transform converts almost any probability distribution into a square wave
– Compresses, removes low amplitude variations
Instance Method Summary collapse
-
#fisher_transform(value) ⇒ Object
The absolute value passed must be < 1.0.
-
#ift(value, scale_factor = 1.0) ⇒ Object
inverse fisher transform www.mql5.com/en/articles/303.
Instance Method Details
#fisher_transform(value) ⇒ Object
The absolute value passed must be < 1.0
30 31 32 33 34 35 |
# File 'lib/quant/mixins/fisher_transform.rb', line 30 def fisher_transform(value) r = 0.5 * Math.log((1.0 + value) / (1.0 - value)) r.nan? ? 0.0 : r rescue Math::DomainError => e raise "value #{value}: #{(1 + value) / (1 - value)}, e: #{e}" end |
#ift(value, scale_factor = 1.0) ⇒ Object
inverse fisher transform www.mql5.com/en/articles/303
17 18 19 20 |
# File 'lib/quant/mixins/fisher_transform.rb', line 17 def ift(value, scale_factor = 1.0) r = (Math.exp(2.0 * scale_factor * value) - 1.0) / (Math.exp(2.0 * scale_factor * value) + 1.0) r.nan? ? 0.0 : r end |