Example #1
0
 static DistributionRow[] LoadData(string filename)
 {
     return(File.ReadAllLines(filename).Select(l => {
         var spl = l.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
         try {
             var res = new DistributionRow {
                 DateTime = DateTime.Parse(spl[0]).Add(TimeSpan.Parse(spl[1])),
                 Duration = int.Parse(spl[2]),
                 Page = spl[3]
             };
             return res;
         }
         catch {
             return null;
         }
     }).Where(r => r != null).ToArray());
 }
Example #2
0
 private string getSignificanceStatement(DistributionRow dr, double tVal)
 {
     if (tVal > dr.PointZeroZeroOne)
     {
         return(DistributionTable.PointZeroZeroOneStatement);
     }
     else if (tVal > dr.PointZeroOne)
     {
         return(DistributionTable.PointZeroOneStatement);
     }
     else if (tVal > dr.PointZeroFive)
     {
         return(DistributionTable.PointZeroFiveStatement);
     }
     else if (tVal > dr.PointOne)
     {
         return(DistributionTable.PointOneStatement);
     }
     else
     {
         return(DistributionTable.NoSignificanceStatement);
     }
 }
Example #3
0
        private void ShowCalculations(Dictionary <string, List <PatternShapeModel> > patternShapes)
        {
            List <PatternShapeModel> Z          = patternShapes["Z"];
            List <PatternShapeModel> X          = patternShapes["X"];
            ConvertedScoreTable      scoreTable = new ConvertedScoreTable();

            int[] idealJDQA = PatternShapeFunctions.calculateIdealJDQA(Z);
            IdealJDQAText.Content = string.Format("Job Demands Quotient: {0}{1}{2}{3}", idealJDQA[0], idealJDQA[1], idealJDQA[2], idealJDQA[3]);

            List <ConvertedScoreRow> zConvertedScores = new List <ConvertedScoreRow>();
            List <ConvertedScoreRow> xConvertedScores = new List <ConvertedScoreRow>();

            for (int i = 0; i < Z.Count(); i++)
            {
                double            r         = calculateR(PatternShapeFunctions.sliceCQ(Z[i].PS), idealJDQA);
                int               modifiedR = (int)Math.Round(r * 100, MidpointRounding.AwayFromZero);
                ConvertedScoreRow zScoreRow = scoreTable.ConversionRows[modifiedR];
                zConvertedScores.Add(zScoreRow);
                double convertedScore = zScoreRow.Score;
                Label  zLabel         = new Label();
                zLabel.Content = string.Format("z{0} R Value: {1} Converted Score: {2}", i + 1, Math.Round(r, 2), convertedScore);

                //        ZResults.Children.Add(zLabel);
            }

            for (int i = 0; i < X.Count(); i++)
            {
                double            r         = calculateR(PatternShapeFunctions.sliceCQ(X[i].PS), idealJDQA);
                int               modifiedR = (int)Math.Round(r * 100, MidpointRounding.AwayFromZero);
                ConvertedScoreRow xScoreRow = scoreTable.ConversionRows[modifiedR];
                xConvertedScores.Add(xScoreRow);
                double convertedScore = xScoreRow.Score;
                Label  xLabel         = new Label();
                xLabel.Content = String.Format("x{0} R Value: {1} Converted Score: {2}", i + 1, Math.Round(r, 2), convertedScore);

                //         XResults.Children.Add(xLabel);
            }

            double c = zConvertedScores.Sum(z => z.Score);

            Label cLabel = new Label();

            cLabel.Content = String.Format("c value: {0}", c);
            //      CalculatedValues.Children.Add(cLabel);

            double x1      = c / zConvertedScores.Count();
            Label  x1Label = new Label();

            x1Label.Content = String.Format("x1 value: {0}", Math.Round(x1, 2, MidpointRounding.AwayFromZero));
            //       CalculatedValues.Children.Add(x1Label);


            double d      = xConvertedScores.Sum(x => x.Score);
            Label  dLabel = new Label();

            dLabel.Content = String.Format("d value: {0}", d);
            //       CalculatedValues.Children.Add(dLabel);

            double x2 = d / xConvertedScores.Count();

            Label x2Label = new Label();

            x2Label.Content = String.Format("x2 value: {0}", Math.Round(x2, 2, MidpointRounding.AwayFromZero));
            //       CalculatedValues.Children.Add(x2Label);

            double a = zConvertedScores.Sum(z => z.Score * z.Score);

            Label aLabel = new Label();

            aLabel.Content = String.Format("a value: {0}", a);
            //     CalculatedValues.Children.Add(aLabel);

            double b = xConvertedScores.Sum(x => x.Score * x.Score);

            Label bLabel = new Label();

            bLabel.Content = String.Format("b value: {0}", b);
            //     CalculatedValues.Children.Add(bLabel);

            double n1      = zConvertedScores.Count();
            Label  n1Label = new Label();

            n1Label.Content = String.Format("n1 value: {0}", n1);
            //   CalculatedValues.Children.Add(n1Label);

            double n2      = xConvertedScores.Count();
            Label  n2Label = new Label();

            n2Label.Content = String.Format("n2 value: {0}", n2);
            //   CalculatedValues.Children.Add(n2Label);

            double S      = (a - ((c * c) / n1)) + (b - ((d * d) / n2));
            Label  sLabel = new Label();

            sLabel.Content = String.Format("S value: {0}", Math.Round(S, 2, MidpointRounding.AwayFromZero));
            //   CalculatedValues.Children.Add(sLabel);

            double R      = Math.Sqrt((S / ((n1 + n2) - 2)) * ((1 / n1) + (1 / n2)));
            Label  rLabel = new Label();

            rLabel.Content = String.Format(@"

Regarding individuals being considered for this position, any ITS Self Concept Pattern Shape with a compatibility (COM) of between
.70 and 1.00 would be an excellent match from a behavioral stand point.  From .40 to .69 would be considered a good match.
.10 to .39 a fair match and from -  (minus) 1.00 to + .09 a poor match.", R);

            double T      = (x1 - x2) / R;
            Label  tLabel = new Label();

            tLabel.Content = String.Format("\r\n T value: {0}", Math.Round(T, 2, MidpointRounding.AwayFromZero));
            //           CalculatedValues.Children.Add(tLabel);

            int   df      = (int)(n1 + n2 - 2);
            Label dfLabel = new Label();

            dfLabel.Content = String.Format("\r\n df value: {0}", df);
            //           CalculatedValues.Children.Add(dfLabel);

            Label             distributionLabel = new Label();
            DistributionTable dTable            = new DistributionTable();
            DistributionRow   dr = dTable._distributionRows.ContainsKey(df) ? dTable._distributionRows[df] : dTable._distributionRows[0];

            string significanceStatement = getSignificanceStatement(dr, T);

            Label significanceLabel = new Label();

            significanceLabel.Content = significanceStatement;
            CalculatedValues.Children.Add(significanceLabel);

            CalculatedValues.Children.Add(rLabel);
        }
 public DistributionRowChangeEvent(DistributionRow row, System.Data.DataRowAction action) {
     this.eventRow = row;
     this.eventAction = action;
 }
 public void RemoveDistributionRow(DistributionRow row) {
     this.Rows.Remove(row);
 }
 public void AddDistributionRow(DistributionRow row) {
     this.Rows.Add(row);
 }
        public void DoQuestionE()
        {
            //The degree distribution of inlinks and outlinks

            //outlinks
            List<DistributionRow> distribution_outlinks = new List<DistributionRow>(); //the distribution list
            DistributionRow row = null; //row that is inserted into the list
            numberOfOutlinks.Sort(); //sort the list and then iterate through

            for(int i = 0; i < numberOfOutlinks.Count; i++)
            {
                if (i == 0 || row.numberLinks != numberOfOutlinks[i])//start a new row
                {
                    if (row != null) { distribution_outlinks.Add(row); }
                    row = new DistributionRow(numberOfOutlinks[i]);
                }

                row.numberPages++;

            }//each numberOfOutlinks

            //write to a file
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileFolder + "2e_outlinks.txt"))
            {
                file.WriteLine("# outlinks \t # pages");
                for(int i = 0; i < distribution_outlinks.Count; i++)
                {
                    file.WriteLine(distribution_outlinks[i].numberLinks + " \t " + distribution_outlinks[i].numberPages);
                }

            }

            //inlinks
            List<DistributionRow> distribution_inlinks = new List<DistributionRow>(); //the distribution list
            row = null; //row that is inserted into the list
            numberOfInlinks.Sort(); //sort the list and then iterate through

            for (int i = 0; i < numberOfInlinks.Count; i++)
            {
                if (i == 0 || row.numberLinks != numberOfInlinks[i])//start a new row
                {
                    if (row != null) { distribution_inlinks.Add(row); }
                    row = new DistributionRow(numberOfInlinks[i]);
                }

                row.numberPages++;

            }//each numberOfOutlinks

            //write to a file
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileFolder + "2e_inlinks.txt"))
            {
                file.WriteLine("# inlinks \t # pages");
                for (int i = 0; i < distribution_inlinks.Count; i++)
                {
                    file.WriteLine(distribution_inlinks[i].numberLinks + " \t " + distribution_inlinks[i].numberPages);
                }

            }
        }