using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
namespace Законы_распределения.Распределения
{
public class Functoins
{
private Распределения.OutValues ouVal;
private Распределения.EnterValues enVal;
private double[] arA;
public Functoins(Распределения.OutValues ouVal, Распределения.EnterValues enVal)
{
this.ouVal = ouVal;
this.enVal = enVal;
arA = new double[enVal._Ntb];
}
public double maxX(double[] arX)
{
double max = 0;
double[] sortArX = new double[enVal._N];
for (int i = 0; i < enVal._N; i++)
{
if (arX[i] > max)
{
max = Math.Abs(arX[i]);
}
}
return max;
}
public double minX(double[] arX)
{
double min = 0;
double[] sortArX = new double[enVal._N];
for (int i = 0; i < enVal._N; i++)
{
if (arX[i] < min)
{
min = arX[i];
}
}
return min;
}
public double Abs(double Num)
{
double X;
if (Num < 0)
{
X = (-1) * Num;
}
else
{
X = Num;
}
return X;
}
public double MatOX()
{
double sumX = 0.0;
double mx = 0;
for (int i = 0; i < enVal._N; i++)
{
sumX += ouVal._arX[i];
}
mx = sumX / (double)enVal._N;
return mx;
}
public double DispX(double MatO)
{
double sumX2 = 0;
double dx = 0.0;
for (int i = 0; i < enVal._N; i++)
{
sumX2 += Math.Pow(ouVal._arX[i], 2.0);
}
dx = (sumX2 / (double)enVal._N) - Math.Pow(MatO, 2.0);
return dx;
}
public double SkoX(double Disp)
{
double qx = 0.0;
qx = Math.Sqrt(Disp);
return qx;
}
public double Xi2(int i)
{
double xi2 = 0.0;
xi2 = Math.Pow((ouVal._arTable[i, 3] - ouVal._arTable[i, 2]), 2.0) / ouVal._arTable[i, 3];
return xi2;
}
public double sumXi2(double[,] arTable)
{
double sum = 0.0;
for (int i = 0; i < enVal._Ntb; i++)
{
sum += arTable[i, 6];
}
return sum;
}
private double h(double Int)
{
double h = 0.0;
h = Int / 2.0;
return h;
}
public double fR(double Int, int i)
{
double R=0.0;
R = 0.1;
return R;
}
public double fNorm(double Int, int i)
{
double norm, tmp1, tmp2, tmp3;
arA[i] = ouVal._arTable[i, 1] - h(Int);
tmp1 = 1.0 / (enVal._Sko_T * Math.Sqrt(2.0 * Math.PI));
tmp2 = (-1.0) * (Math.Pow((arA[i] - enVal._MatO_T), 2.0)) / (2.0 * Math.Pow(enVal._Sko_T, 2.0));
tmp3 = Math.Exp(tmp2);
norm = tmp1 * tmp3 * Int;
return norm;
}
public void varR_T()
{
double P = 1.0;
double C = 12.0;
ouVal._MatO_T = 0.5;
ouVal._Disp_T = P / C;
}
public void varNorm_T()
{
ouVal._MatO_T = enVal._MatO_T;
ouVal._Disp_T = Math.Pow(enVal._Sko_T, 2.0);
}
public OutValues fAvgAll(ArrayList needCollection)
{
OutValues ouValAvg = new OutValues();
int nCountCollect = needCollection.Count;
ouValAvg._arTable = new double[enVal._Ntb, 7];
//
for (int i = 0; i < nCountCollect; i++)
{
ouVal = (OutValues)needCollection[i];
ouValAvg._MatO += ouVal._MatO / (double)nCountCollect;
ouValAvg._Disp += ouVal._Disp / (double)nCountCollect;
ouValAvg._Sko += ouVal._Sko / (double)nCountCollect;
ouValAvg._maxfFR += ouVal._maxfFR / (float)nCountCollect;
int nColArTable = 7;
for (int j = 0; j < nColArTable; j++)
{
for (int i_tbl = 0; i_tbl < enVal._Ntb; i_tbl++)
{
ouValAvg._arTable[i_tbl, j] += ouVal._arTable[i_tbl, j] / (double)nCountCollect;
}
}
int nRowArX = ouVal._arX.Length;
ouValAvg._arX = new double[nRowArX];
for (int iR = 0; iR < nRowArX; iR++)
{
ouValAvg._arX[iR] += ouVal._arX[iR] / nCountCollect;
}
}
ouVal = (OutValues)needCollection[nCountCollect-1];
ouValAvg._MatO_T = ouVal._MatO_T;
ouValAvg._Disp_T = ouVal._Disp_T;
ouValAvg._Sko_T = ouVal._Sko_T;
ouValAvg._Xi2_T = ouVal._Xi2_T;
return ouValAvg;
}
private float maxfF()
{
float max = 0;
for (int i = 0; i < enVal._Ntb; i++)
{
if (max > ouVal._arTable[i, 5])
{
max = max;
}
else
{
max = (float)ouVal._arTable[i, 5];
}
}
return max;
}
private float maxfR()
{
float max = 0;
for (int i = 0; i < enVal._Ntb; i++)
{
if (max > ouVal._arTable[i, 4])
{
max = max;
}
else
{
max = (float)ouVal._arTable[i, 4];
}
}
return max;
}
public float maxFR()
{
float max = 0;
max = Math.Max(maxfF(), maxfR());
return max;
}
}
}