private void btnOK_Click(object sender, EventArgs e) { frmWaitDialog frmWait = new frmWaitDialog("正在汇总...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; SampleSummary summary = new SampleSummary(_pSampleLayer, _pSurveyLayer, cmbFieldVillage.Text, cmbFieldID.Text, cmbFieldCropType.Text, cmbCropName.Text, cmbFieldArea.Text, txtOut.Text); string msg = ""; if (!summary.Summary(out msg)) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (DialogResult.OK == XtraMessageBox.Show("汇总完成!", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { //MapAPI.AddShpFileToMap(txtOut.Text); BLL.EnviVars.instance.MapControl.Refresh(); } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } finally { frmWait.Close(); XtraMessageBox.Show("汇总完成!"); _pMapControl.Refresh(); _pTOCControl.Update(); } }
/// <summary> /// Computes the log-normal distribution that best fits the given sample. /// </summary> /// <param name="sample">The sample to fit.</param> /// <returns>The best fit parameters.</returns> /// <remarks> /// <para>The returned fit parameters are the μ (<see cref="Mu"/>) and σ (<see cref="Sigma"/>) parameters, in that order. /// These are the same parameters, in the same order, that are required by the <see cref="LognormalDistribution(double,double)"/> constructor to /// specify a new log-normal distribution.</para> /// </remarks> /// <exception cref="ArgumentNullException"><paramref name="sample"/> is null.</exception> /// <exception cref="InsufficientDataException"><paramref name="sample"/> contains fewer than three values.</exception> /// <exception cref="InvalidOperationException"><paramref name="sample"/> contains non-positive values.</exception> public static FitResult FitToSample(Sample sample) { if (sample == null) { throw new ArgumentNullException(nameof(sample)); } if (sample.Count < 3) { throw new InsufficientDataException(); } // Writing out the log likelyhood from p(x), taking its // derivatives wrt mu and sigma, and setting them equal // to zero to find the minimizing values, you find that // the results of the normal fit are reproduced exactly // with x -> log x, i.e. // \mu = < \log x >, \sigma^2 = < (\log x - \mu)^2 > // do a one-pass computation of these quantities SampleSummary summary = new SampleSummary(); foreach (double value in sample) { if (value <= 0.0) { throw new InvalidOperationException(); } summary.Add(Math.Log(value)); } // the second derivatives are also just as in the normal // case, including the vanishing of the mixed derivative // this makes direct inversion trivial SymmetricMatrix C = new SymmetricMatrix(2); C[0, 0] = summary.Variance / summary.Count; C[1, 1] = summary.Variance / summary.Count / 2; // test the fit ContinuousDistribution d = new LognormalDistribution(summary.Mean, Math.Sqrt(summary.Variance)); TestResult r = sample.KolmogorovSmirnovTest(d); return(new FitResult(new double[] { summary.Mean, Math.Sqrt(summary.Variance) }, C, r)); }
public async Task <ListResponse <SampleSummary> > GetSamplesForLabelAsync(string labelId, string contentType, EntityHeader org, EntityHeader user, ListRequest request) { var label = await _labelRepo.GetLabelAsync(labelId); await AuthorizeAsync(label, AuthorizeResult.AuthorizeActions.Read, user, org); var samples = await _sampleLabelRepo.GetSamplesForLabelAsync(labelId, contentType, request); return(new ListResponse <SampleSummary>() { Model = samples.Model.Select(smp => SampleSummary.FromSampleLabel(smp)), NextPartitionKey = samples.NextPartitionKey, NextRowKey = samples.NextRowKey, PageCount = samples.PageCount, PageIndex = samples.PageIndex, PageSize = samples.PageSize }); }