Ejemplo n.º 1
0
 private Objects.ExcelGroup[][] BuildGroups(double Enclosing)
 {
     Objects.ExcelGroup[][] excelGroupsArray = new Objects.ExcelGroup[inputHumen[0].NormalizedRanges.Length][];
     for (int column = 0; column < inputHumen[0].NormalizedRanges.Length; column++)
     {
         Objects.ExcelGroup[] excelGroups = new Objects.ExcelGroup[analizedTuplesArray[column].analizedGroups.Length];
         for (int group = 0; group < analizedTuplesArray[column].analizedGroups.Length; group++)
         {
             Objects.AnalizedGroup currentAnalizedGroup = analizedTuplesArray[column].analizedGroups[group];
             excelGroups[group] = new Objects.ExcelGroup(currentAnalizedGroup.percent, currentAnalizedGroup.mediana, group);
             double[] Squares = new double[currentAnalizedGroup.participatns.Length];
             double[] Qubes   = new double[currentAnalizedGroup.participatns.Length];
             for (int part = 0; part < currentAnalizedGroup.participatns.Length; part++)
             {
                 Squares[part] = Math.Pow(currentAnalizedGroup.participatns[part] - currentAnalizedGroup.mediana, 2);
                 Qubes[part]   = Math.Pow(currentAnalizedGroup.participatns[part] - currentAnalizedGroup.mediana, 3);
             }
             excelGroups[group].standartDerivation = Math.Sqrt(Squares.Sum() / (Squares.Length - 1));
             excelGroups[group].min       = currentAnalizedGroup.min;
             excelGroups[group].max       = currentAnalizedGroup.max;
             excelGroups[group].count     = currentAnalizedGroup.count;
             excelGroups[group].assymetry = Qubes.Sum() / (Squares.Length * Math.Pow(currentAnalizedGroup.dispersia, 3));
             excelGroups[group].vars      = currentAnalizedGroup.participatns;
             if (group < analizedTuplesArray[column].analizedGroups.Length - 1)
             {
                 Objects.AnalizedGroup nextAnalizedGroup = analizedTuplesArray[column].analizedGroups[group + 1];
                 double Mean1    = currentAnalizedGroup.participatns.Average();
                 double Mean2    = nextAnalizedGroup.participatns.Average();
                 double Mediana1 = currentAnalizedGroup.mediana;
                 double Mediana2 = nextAnalizedGroup.mediana;
                 double NormAll  = analizedTuplesArray[column].max - analizedTuplesArray[column].min;
                 double Min1     = currentAnalizedGroup.min;
                 double Max1     = currentAnalizedGroup.max;
                 double Min2     = nextAnalizedGroup.min;
                 double Max2     = nextAnalizedGroup.max;
                 excelGroups[group].closingTo = CoeffCounter(Mean1, Mean2, Mediana1, Mediana2, NormAll, Min1, Max1, Min2, Max2);
             }
         }
         excelGroups = Encloser(excelGroups, Enclosing, column);
         excelGroupsArray[column] = excelGroups;
     }
     this.builded = excelGroupsArray;
     return(excelGroupsArray);
 }
Ejemplo n.º 2
0
 private Objects.ExcelGroup[] Encloser(Objects.ExcelGroup[] BuildGroups, double Enclosing, int column)
 {
     BuildGroups = BuildGroups.OrderByDescending(x => x.closingTo).ToArray();
     if (BuildGroups[0].closingTo > Enclosing)
     {
         List <Objects.ExcelGroup> excelGroupsList = BuildGroups.ToList();
         Objects.ExcelGroup        firstGroup      = BuildGroups[0];
         Objects.ExcelGroup        secondGroup     = BuildGroups.FirstOrDefault(x => x.number == firstGroup.number + 1);
         double        weightFirst  = (double)firstGroup.count / (firstGroup.count + secondGroup.count);
         double        weightSecond = (double)secondGroup.count / (firstGroup.count + secondGroup.count);
         double        meadiana     = weightFirst * firstGroup.mediana + weightSecond * secondGroup.mediana;
         double        percent      = firstGroup.percent + secondGroup.percent;
         double        mean         = (secondGroup.max - firstGroup.min) / 2;
         List <double> fV           = firstGroup.vars.ToList();
         List <double> lV           = secondGroup.vars.ToList();
         List <double> sV           = secondGroup.vars.ToList();
         sV.AddRange(fV);
         double[] cV = new double[sV.Count];
         cV = sV.ToArray();
         double[] ScV = new double[cV.Length];
         double[] QcV = new double[cV.Length];
         for (int v = 0; v < cV.Length; v++)
         {
             ScV[v] = Math.Pow(cV[v] - mean, 2);
             QcV[v] = Math.Pow(cV[v] - mean, 3);
         }
         Objects.ExcelGroup compound = new Objects.ExcelGroup(percent, meadiana, 0)
         {
             min   = firstGroup.min,
             max   = secondGroup.max,
             count = firstGroup.count + secondGroup.count,
             vars  = cV,
             standartDerivation = Math.Sqrt(ScV.Sum() / (ScV.Length - 1)),
             assymetry          = QcV.Sum() / (QcV.Length * Math.Pow(ScV.Sum() / ScV.Length, (3 / 2)))
         };
         excelGroupsList.Remove(firstGroup);
         excelGroupsList.Remove(secondGroup);
         excelGroupsList.Add(compound);
         excelGroupsList = excelGroupsList.OrderBy(x => x.mediana).ToList();
         for (int group = 0; group < excelGroupsList.Count; group++)
         {
             excelGroupsList[group].number = group;
             if (group < excelGroupsList.Count - 1)
             {
                 Objects.ExcelGroup nextExcelGroup    = excelGroupsList[group + 1];
                 Objects.ExcelGroup currentExcelGroup = excelGroupsList[group];
                 double             Mean1             = fV.Average();
                 double             Mean2             = lV.Average();
                 double             Mediana1          = currentExcelGroup.mediana;
                 double             Mediana2          = nextExcelGroup.mediana;
                 double             NormAll           = analizedTuplesArray[column].max - analizedTuplesArray[column].min;
                 double             Min1 = currentExcelGroup.min;
                 double             Max1 = currentExcelGroup.max;
                 double             Min2 = nextExcelGroup.min;
                 double             Max2 = nextExcelGroup.max;
                 excelGroupsList[group].closingTo = CoeffCounter(Mean1, Mean2, Mediana1, Mediana2, NormAll, Min1, Max1, Min2, Max2);
             }
         }
         Objects.ExcelGroup[] reTry = new Objects.ExcelGroup[excelGroupsList.Count];
         reTry       = excelGroupsList.ToArray();
         BuildGroups = Encloser(reTry, Enclosing, column);
     }
     BuildGroups = BuildGroups.OrderBy(x => x.mediana).ToArray();
     return(BuildGroups);
 }