private void getCov() { if (varcovpath != null) { varCov = new dataPrepVarCovCorr(); varCov.buildModel(varcovpath); if (intable == null && inraster == null) { VariableFieldNames = varCov.VariableFieldNames; inpath = varCov.InPath; intable = geoUtil.getTable(inpath); if (intable == null) { inraster = rsUtil.returnRaster(inpath); } } } else { if (InRaster == null) { varCov = new dataPrepVarCovCorr(InTable, VariableFieldNames); } else { varCov = new dataPrepVarCovCorr(InRaster); } } meanVector = varCov.MeanVector; stdVector = varCov.StdVector; corr = varCov.CorralationMatrix; n = varCov.N; }
private static void fillCovCorr(string modelPath, Forms.RunningProcess.frmRunningProcessDialog rp, double proportion = 0.1, double alpha = 0.05) { dataPrepVarCovCorr covCorr = new dataPrepVarCovCorr(); covCorr.buildModel(modelPath); double[,] covCorrArr = covCorr.CovarianceMatrix; double[] means = covCorr.MeanVector; string[] varFieldNames = covCorr.VariableFieldNames; int[] nAndIndex = sampleSizeMaxMean(covCorrArr, means, proportion, alpha); string vName = varFieldNames[nAndIndex[1]]; double mean = means[nAndIndex[1]]; double std = covCorr.StdVector[nAndIndex[1]]; rp.addMessage("\nTotal Number of Samples = " + nAndIndex[0].ToString() + "\n\nMax sample from variable " + vName + "\n\tMean = " + mean.ToString() + "\n\tSTD = " + std.ToString()); }
private void createCovCorrModel(string[] paramArr) { Statistics.dataPrepVarCovCorr dpVc = null; if (paramArr.Length > 3) { ITable table = getTable(paramArr[1]); string[] variables = paramArr[2].Split(new char[] { ',' }); dpVc = new Statistics.dataPrepVarCovCorr(table, variables); } else { IRaster rs = rsUtil.createRaster(getRaster(paramArr[1])); dpVc = new Statistics.dataPrepVarCovCorr(rs); } dpVc.writeModel(paramArr[paramArr.Length - 1]); }
private static void fillCovCorr(string modelPath, Forms.RunningProcess.frmRunningProcessDialog rp, double proportion = 0.1, double alpha = 0.05) { dataPrepVarCovCorr covCorr = new dataPrepVarCovCorr(); covCorr.buildModel(modelPath); double[,] covCorrArr = covCorr.CovarianceMatrix; double[] means = covCorr.MeanVector; string[] varFieldNames = covCorr.VariableFieldNames; int[] nAndIndex = sampleSizeMaxMean(covCorrArr,means, proportion, alpha); string vName = varFieldNames[nAndIndex[1]]; double mean = means[nAndIndex[1]]; double std = covCorr.StdVector[nAndIndex[1]]; rp.addMessage("\nTotal Number of Samples = " + nAndIndex[0].ToString() + "\n\nMax sample from variable " + vName + "\n\tMean = " + mean.ToString() + "\n\tSTD = " +std.ToString()); }
private void getCov() { if (varcovpath != null) { varCov = new dataPrepVarCovCorr(); varCov.buildModel(varcovpath); if (intable == null && inraster == null) { VariableFieldNames = varCov.VariableFieldNames; inpath = varCov.InPath; intable= geoUtil.getTable(inpath); if (intable == null) { inraster = rsUtil.returnRaster(inpath); } } } else { if (InRaster == null) { varCov = new dataPrepVarCovCorr(InTable, VariableFieldNames); } else { varCov = new dataPrepVarCovCorr(InRaster); } } meanVector = varCov.MeanVector; stdVector = varCov.StdVector; corr = varCov.CorralationMatrix; n = varCov.N; }
public void selectCovCorrFeaturesToSample(ITable inputTable, string covCorrModelPath, double proptionOfMean=0.1, double alpha = 0.05) { IObjectClassInfo2 objInfo2 = (IObjectClassInfo2)inputTable; if (!objInfo2.CanBypassEditSession()) { System.Windows.Forms.MessageBox.Show("Input Table participates in a composite relationship. Please export this table as a new table and try again!"); return; } Statistics.dataPrepVarCovCorr covCor = new Statistics.dataPrepVarCovCorr(); covCor.buildModel(covCorrModelPath); System.Random rd = new Random(); double tSamples = System.Convert.ToDouble(esriUtil.Statistics.dataPrepSampleSize.sampleSizeMaxMean(covCor.MeanVector,covCor.StdVector,proptionOfMean,alpha)); int tRecords = inputTable.RowCount(null); double gR = tSamples / tRecords; string sampleFldName = geoUtil.createField(inputTable, "sample", esriFieldType.esriFieldTypeSmallInteger, false); IQueryFilter qf0 = new QueryFilterClass(); IQueryFilter qf = new QueryFilterClass(); qf.SubFields = sampleFldName; IWorkspace wks = ((IDataset)inputTable).Workspace; IWorkspaceEdit wksE = (IWorkspaceEdit)wks; if (wksE.IsBeingEdited()) { wksE.StopEditing(true); } try { ICursor cur = inputTable.Update(qf, false); int sIndex = cur.FindField(sampleFldName); IRow rw = cur.NextRow(); while (rw != null) { double rNum = rd.NextDouble(); int ss = 0; double r = gR; if (rNum < r) { ss = 1; } rw.set_Value(sIndex, ss); cur.UpdateRow(rw); rw = cur.NextRow(); } System.Runtime.InteropServices.Marshal.ReleaseComObject(cur); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString()); } }