コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            Console.WriteLine("Building query....");
            var factory = new SimpleSQLFactory(this.visualQueryBuilder1.SelectedTableName, new List<string>()
            {
                this.visualQueryBuilder1.SelectedFieldName,
                this.visualQueryBuilder1.SelectedRowGroupingFieldName,
                this.visualQueryBuilder1.SelectedColGroupingFieldName
            });

            var db = new AccessDatabase(this.textboxWithOpenFileDialog1.Text);
            var builder = new StandardQueryBuilder(factory);
            Console.WriteLine("Retrieving data from access...");
            DataTable results = db.ExecuteQuery(builder.BuildSQL());

            try
            {
                Console.WriteLine("Calculating aggregate statistics");
                var statistics = new BasicStatistics(results, 0);
                var visualiser = new DataVisualisation.BasicStatisticsVisualiser(statistics);
                this.explorationPanel1.SetAggregateResults(visualiser);

            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.Message +
                        " Please make sure you have selected quantitative variables for the analysis", "Error analysing query dataset",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InvalidCastException ex)
            {
                MessageBox.Show(ex.Message +
                            " Please make sure you have selected quantitative variables for the analysis", "Error analysing query dataset",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

            var adapter = new DataTableToCrossTabAdapter(results, new DataTableToCrossTabAdapterArgs()
            {
                RowFieldNames = new List<string>(){this.visualQueryBuilder1.SelectedRowGroupingFieldName},
                ColFieldNames = new List<string>(){this.visualQueryBuilder1.SelectedColGroupingFieldName}
            });

            Console.WriteLine("Building crosstab...");

            var ctDataTable = new CrossTabDataTable(adapter, this.visualQueryBuilder1.SelectedRowGroupingFieldName);
            this.explorationPanel1.SetCrossTab(ctDataTable);
            this.extendedTabControl1.SelectedTab = this.tabPage4;

            Console.WriteLine("Complete.");
        }
コード例 #2
0
        /// <summary>
        /// Overloaded constructor.  Inverts a basic statistics object
        /// </summary>
        /// <param name="statistics">Contains the basic statistics</param>
        public BasicStatisticsVisualiser(BasicStatistics statistics)
        {
            this.statistics = new Dictionary<string, double>();

            AddStatistic(SAMPLE_SIZE, statistics.N);
            AddStatistic(MEAN, statistics.Mean);
            AddStatistic(STANDARD_DEV, statistics.StdDev);
            AddConfidenceIntervalStatisics(statistics);
            AddStatistic(MEDIAN, statistics.Median);
            AddStatistic(IQR, statistics.IQR);
            AddStatistic(LOWER_QUARTILE, statistics.Percentile(0.25));
            AddStatistic(UPPER_QUARTILE, statistics.Percentile(0.75));
            AddStatistic(FIFTH_PERCENTILE, statistics.Percentile(0.05));
            AddStatistic(NINTYFIFTH_PERCENTILE, statistics.Percentile(0.95));
            AddStatistic(MINIMUM, statistics.Minimum);
            AddStatistic(MAXIMUM, statistics.Maximum);
        }
コード例 #3
0
 /// <summary>
 /// Overloaded constructor
 /// </summary>
 /// <param name="statistics">Basic statistics for data</param>
 /// <param name="level">Chosen confidence level</param>
 public ConfidenceIntervalStandardNormal(BasicStatistics statistics, ConfidenceLevel level)
 {
     this.statistics = statistics;
     this.level = level;
 }
コード例 #4
0
 /// <summary>
 /// Constructor: assumes 95% confidence level
 /// </summary>
 /// <param name="statistics">Basic statistics for data</param>
 public ConfidenceIntervalStandardNormal(BasicStatistics statistics)
 {
     this.statistics = statistics;
     this.level = ConfidenceLevel.NinetyFive;
 }
コード例 #5
0
 protected void AddConfidenceIntervalStatisics(BasicStatistics statistics)
 {
     var ci = new ConfidenceIntervalStandardNormal(statistics);
     AddStatistic(STANDARD_ERROR, ci.StandardError);
     AddStatistic(LOWER_CONFIDENCE_INTERVAL, ci.LowerBound);
     AddStatistic(UPPER_CONFIDENCE_INTERVAL, ci.UpperBound);
 }
コード例 #6
0
        private void RecordAllocationResult()
        {
            BasicStatistics stats = new BasicStatistics(this.allDistances);
            var CI = new ConfidenceIntervalStandardNormal(stats);

            this.allocationResult = new AllocationResult()
            {
                Mean = stats.Mean,
                LCI = CI.LowerBound,
                UCI = CI.UpperBound,
                Stats = stats,
            };
        }
コード例 #7
0
        /// <summary>
        /// Create a LocalityResult object to store result for locality
        /// </summary>
        /// <param name="locality">Name of locality</param>
        /// <param name="data">data points for locality</param>
        protected void RecordLocalityResults(string locality, List<double> data)
        {
            BasicStatistics stats = new BasicStatistics(data);
            var CI = new ConfidenceIntervalStandardNormal(stats);

            var localityResult = new LocalityResult()
            {
                Locality = locality,
                Mean = Math.Round(stats.Mean, DECIMAL_PLACES),
                LCI = Math.Round(CI.LowerBound, DECIMAL_PLACES),
                UCI = Math.Round(CI.UpperBound, DECIMAL_PLACES),
                FifthPercentile = Math.Round(stats.Percentile(FIFTH_PERCENTILE), DECIMAL_PLACES),
                NinetyFifthPercentile = Math.Round(stats.Percentile(NINETYFIFTH_PERCENTILE), DECIMAL_PLACES)
            };

            resultsByLocality.Add(localityResult);
        }
コード例 #8
0
 /// <summary>
 /// Overloaded constructor
 /// </summary>
 /// <param name="statsVariable1">Statistics object for variable 1</param>
 /// <param name="statsVariable2">Statistics object for variable 2</param>
 /// <param name="level">Chosen confidence level</param>
 public ConfidenceIntervalForMeanDifference(BasicStatistics statsVariable1, BasicStatistics statsVariable2, ConfidenceLevel level)
 {
     this.statsVariable1 = statsVariable1;
     this.statsVariable2 = statsVariable2;
     this.level = level;
 }
コード例 #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="statsVariable1">Statistics object for variable 1</param>
 /// <param name="statsVariable2">Statistics object for variable 2</param>
 public ConfidenceIntervalForMeanDifference(BasicStatistics statsVariable1, BasicStatistics statsVariable2)
 {
     this.statsVariable1 = statsVariable1;
     this.statsVariable2 = statsVariable2;
     this.level = ConfidenceLevel.NinetyFive;
 }