4 八月 2022
4 八月 2022
程序端
MQL5
//--- matrix a= {{1, 4}, {9, 16}}; Print("matrix a=\n",a); a=MathSqrt(a); Print("MatrSqrt(a)=\n",a); /* matrix a= [[1,4] [9,16]] MatrSqrt(a)= [[1,2] [3,4]] */对于MathMod和MathPow,第二个元素既可以是标量,也可以是相应大小的矩阵/向量。
//+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- Use the initializing function to populate the vector vector r(10, ArrayRandom); // Array of random numbers from 0 to 1 //--- Calculate the average value double avr=r.Mean(); // Array mean value vector d=r-avr; // Calculate an array of deviations from the mean Print("avr(r)=", avr); Print("r=", r); Print("d=", d); vector s2=MathPow(d, 2); // Array of squared deviations double sum=s2.Sum(); // Sum of squared deviations //--- Calculate standard deviation in two ways double std=MathSqrt(sum/r.Size()); Print(" std(r)=", std); Print("r.Std()=", r.Std()); } /* avr(r)=0.5300302133243813 r=[0.8346201971495713,0.8031556138798182,0.6696676534318063,0.05386516922513505,0.5491195410016175,0.8224433118686484,... d=[0.30458998382519,0.2731254005554369,0.1396374401074251,-0.4761650440992462,0.01908932767723626,0.2924130985442671, ... std(r)=0.2838269732183663 r.Std()=0.2838269732183663 */ //+------------------------------------------------------------------+ //| Fills the vector with random values | //+------------------------------------------------------------------+ void ArrayRandom(vector& v) { for(ulong i=0; i<v.Size(); i++) v[i]=double(MathRand())/32767.; }
改进浮点类型运算的数学函数。新实现的将数学函数应用于‘float'矩阵和向量的可能性可以改进应用于‘float'标量的数学函数。以前,这些函数参数被无条件地转换为‘double'类型,然后调用相应实施的数学函数,并将结果转换回‘float'类型。现在,实施这些操作,无需其他类型转换。
以下示例显示了数学正弦计算的差值:
//+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- Array of random numbers from 0 to 1 vector d(10, ArrayRandom); for(ulong i=0; i<d.Size(); i++) { double delta=MathSin(d[i])-MathSin((float)d[i]); Print(i,". delta=",delta); } } /* 0. delta=5.198186103783087e-09 1. delta=8.927621308885136e-09 2. delta=2.131878673594656e-09 3. delta=1.0228555918923021e-09 4. delta=2.0585739779477308e-09 5. delta=-4.199390279957527e-09 6. delta=-1.3221741035351897e-08 7. delta=-1.742922250969059e-09 8. delta=-8.770715820283215e-10 9. delta=-1.2543186267421902e-08 */ //+------------------------------------------------------------------+ //| Fills the vector with random values | //+------------------------------------------------------------------+ void ArrayRandom(vector& v) { for(ulong i=0; i<v.Size(); i++) v[i]=double(MathRand())/32767.; }
AF_ELU | Exponential Linear Unit函数 |
AF_EXP | Exponential函数 |
AF_GELU | Gaussian Error Linear Unit函数 |
AF_HARD_SIGMOID | Hard Sigmoid函数 |
AF_LINEAR | Linear函数 |
AF_LRELU | Leaky REctified Linear Unit函数 |
AF_RELU | REctified Linear Unit函数 |
AF_SELU | Scaled Exponential Linear Unit函数 |
AF_SIGMOID | Sigmoid函数 |
AF_SOFTMAX | Softmax函数 |
AF_SOFTPLUS | SoftPlus函数 |
AF_SOFTSIGN | Softsign函数 |
AF_SWISH | Swish函数 |
AF_TANH | Hyperbolic Tangent函数 |
AF_TRELU | Thresholded REctified Linear Unit函数 |
LOSS_MSE | 均方差损失函数 |
LOSS_MAE | 平均绝对误差损失函数 |
LOSS_CCE | Categorical Crossentropy函数 |
LOSS_BCE | Binary Crossentropy函数 |
LOSS_MAPE | 平均 绝对百分比误差损失函数 |
LOSS_MSLE | 均方对数误差损失函数 |
LOSS_KLD | Kullback-Leibler Divergence函数 |
LOSS_COSINE | Cosine similarity/proximity函数 |
LOSS_POISSON | Poisson函数 |
LOSS_HINGE | Hinge函数 |
LOSS_SQ_HINGE | Squared Hinge函数 |
LOSS_CAT_HINGE | Categorical Hinge函数 |
LOSS_LOG_COSH | 双曲余弦对数 函数 |
LOSS_HUBER | Huber函数 |
int cl_ctx; //--- Initializing the OpenCL context if((cl_ctx=CLContextCreate(CL_USE_GPU_DOUBLE_ONLY))==INVALID_HANDLE) { Print("OpenCL not found"); return; }
CalendarValueLast(change, result, "", "EUR")
MetaEditor
'levels.bmp' as 'uint levels[18990]'