Doğrusal regresyon kanalı - sayfa 13

 
Задача: Подсчет среднего значения и дисперсии числового ряда
Задача: Подсчет среднего значения и дисперсии числового ряда
  • oylar: 2
  • 2015.10.16
  • Google+
  • purecodecpp.com
Эта задача имеет очень большое практическое применение: в статистической обработке данных, обработке временных рядов, в цифровой обработке сигналов применительно к цифровым отсчётам сигнала. Постановка задачи такая: – вводится последовательность (вещественных) чисел … – нужно просчитать, в итоге, среднее значение и дисперсию (или СКО...
 

Şimdi deneyeceğim.

 

Burada 1

İşte hesaplama:

 int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
  {

   int start;
   if (prev_calculated== 0 ){
      start=period;
       double ms= 0 ;
       for ( int i= 0 ;i<period;i++){
         ms+=close[i];
      }
      ma[period- 1 ]=ms/period;
   }
   else {
      start=prev_calculated- 1 ;
   }

   for ( int i=start;i<rates_total;i++){      
       //ma[i]=ma[i-1]+(-close[i-period]+close[i])/period;      
       double s1= 0 ;
       double s2= 0 ;
       for ( int j=i-period+ 1 ;j<=i;j++){
         s1+=close[j];
         s2+=close[j]*close[j];
      }
      s1/=period;
      s2=s2/period-s1*s1;
      Label1Buffer[i]=s2;
   }

   return (rates_total);
  }

Formülü kontrol etmek için hızlandırılmış bir algoritma değil. Belki doğru yapmamıştır?

Dosyalar:
stdX4.mq5  6 kb
 
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot Label1
#property indicator_label1  "Label1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- input parameters
input int      period=14;
//--- indicator buffers
double         Label1Buffer[];

int OnInit()
  {
   SetIndexBuffer(0,Label1Buffer,INDICATOR_DATA);


//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   static double ms,ms2;
   int start;
   if(prev_calculated==0)
     {
      start=period;
      ms=0; ms2=0;
      for(int i=0;i<period;i++)
        {
         ms +=close[i];
         ms2+=close[i]*close[i];
        }
     }
   else
     {
      start=prev_calculated-1;
     }

   for(int i=start;i<rates_total;i++)
     {
      double Ms =ms +(-close[i-period]+close[i]);
      double Ms2=ms2+(-close[i-period]*close[i-period]+close[i]*close[i]);
      double s=Ms/period;
      Label1Buffer[i]=sqrt(s*s+(Ms2-2*Ms*s)/period);
      ms=Ms;
      ms2=Ms2;
     }
   return(rates_total);
  }
 
Yuriy Asaulenko :
Seninle bahse girme. 2. gün sessizlik lütfen.
Zaten Hennessy'yi alamayacaksın.)) Ama kütlemi mahvet.

içmek kötüdür. Soryan. İlk bendim. ))

 

Google " Standart Sapmayı Taşımak"

https://www.johndcook.com/blog/standard_deviation/

Accurately computing running variance
  • www.johndcook.com
The most direct way of computing sample variance or standard deviation can have severe numerical problems. Mathematically, sample variance can be computed as follows. The most obvious way to compute variance then would be to have two sums: one to accumulate the sum of the x‘s and another to accumulate the sums of the squares of the x‘s. If the...
 
Dmitry Fedoseev :

Burada

İşte hesaplama:

Formülü kontrol etmek için hızlandırılmış bir algoritma değil. Belki doğru yapmamıştır?

yeni verilerin gelişini ve eskileri silme ihtiyacını (pencerenin dışında) dikkate almazsınız.

Nikola yapar. mesajınızın altındaki koda bakın.

 

Tamam... son mesajım.

Yuri'nin nereye teslim edeceğini veya sertifika satın alacağını veya nasıl yapılacağını kişisel bir mesajla yazmasına izin verin.

Orada ol. Bir ay sonra ortaya çıkacağım.

 
Nikolai Semko :

içmek kötüdür. Soryan. İlk bendim. ))

Sağlık için. Yarışmak istemedim. Sadece karışmamasını, bilenlerin susmasını istedi.
Algoritma, evet, pratik olarak eşdeğerdir, konunun 1-2 sayfasında bunun hakkında yazdım.
Dmitry, kanıtlanmış olmasına rağmen üzgünüm, ama ne yazık ki Hennessy'yi kabul edemem.
Kodun yazmanın bir anlamı olmadığına inanıyorum. Semko geldi ve hepsi bu ... Öncelik istedim.)) Sanki Dmitry dışında kimse şüphelendi.
Dükkana kendim gitmem gerekecek. ((Bu günlerden biri.
 
Dmitry Fedoseev :

Tamam... son mesajım.

Yuri'nin nereye teslim edeceğini veya sertifika satın alacağını veya nasıl yapılacağını kişisel bir mesajla yazmasına izin verin.

Orada ol. Bir ay sonra ortaya çıkacağım.

İmreniyorum. Verimli çalışma!
Mesajım, bunun yalnızca basit bir Mashka için RMS ile değil, aynı zamanda herhangi bir dereceden bir polinom için de yapılabileceğiydi.
Doğru, formül polinomun derecesi arttıkça üstel olarak büyür.

Neden: