protected override void readResults(int taskID, long allObjectsCount, object taskDescription, out GeneratingStruct generation, out HypothesisStruct[] result) { generation = common.GetGeneratingStruct(taskID); List<HypothesisStruct> hypothesesResult = new List<HypothesisStruct>(); HypothesisStruct hypothesisStruct; AbstractQuantifierSetting quantifierSetting; DataTable hypothesis = common.ExecuteSelectQuery("SELECT * FROM tiHypothesisDF WHERE TaskID=" + taskID); foreach (DataRow hypothese in hypothesis.Rows) { hypothesisStruct = new HypothesisStruct(); hypothesisStruct.booleanLiterals = common.GetBooleanLiterals(taskID, Convert.ToInt32(hypothese["HypothesisID"])); hypothesisStruct.literals = new LiteralStruct[0]; quantifierSetting = new AbstractQuantifierSetting(); quantifierSetting.firstContingencyTableRows = new int[2][]; quantifierSetting.firstContingencyTableRows[0] = new int[2] { Convert.ToInt32(hypothese["FirstFreqA"]), Convert.ToInt32(hypothese["FirstFreqB"]) }; quantifierSetting.firstContingencyTableRows[1] = new int[2] { Convert.ToInt32(hypothese["FirstFreqC"]), Convert.ToInt32(hypothese["FirstFreqD"]) }; quantifierSetting.secondContingencyTableRows = new int[2][]; quantifierSetting.secondContingencyTableRows[0] = new int[2] { Convert.ToInt32(hypothese["SecondFreqA"]), Convert.ToInt32(hypothese["SecondFreqB"]) }; quantifierSetting.secondContingencyTableRows[1] = new int[2] { Convert.ToInt32(hypothese["SecondFreqC"]), Convert.ToInt32(hypothese["SecondFreqD"]) }; quantifierSetting.allObjectsCount = allObjectsCount; hypothesisStruct.quantifierSetting = quantifierSetting; hypothesesResult.Add(hypothesisStruct); } result = hypothesesResult.ToArray(); }
protected override void readResults(int taskID, long allObjectsCount, object taskDescription, out GeneratingStruct generation, out HypothesisStruct[] result) { generation = common.GetGeneratingStruct(taskID); List<HypothesisStruct> hypothesesResult = new List<HypothesisStruct>(); HypothesisStruct hypothesisStruct; AbstractQuantifierSetting quantifierSetting; DataTable hypothesis = common.ExecuteSelectQuery("SELECT * FROM tiHypothesisCF WHERE TaskID=" + taskID); LiteralStruct[] literals = common.GetCategorialLiterals(TaskTypeEnum.CF, taskID, taskDescription); foreach (DataRow hypothese in hypothesis.Rows) { int hypothesisID = Convert.ToInt32(hypothese["HypothesisID"]); hypothesisStruct = new HypothesisStruct(); hypothesisStruct.booleanLiterals = common.GetBooleanLiterals(taskID, hypothesisID); int rowLiteralId = common.CategorialLiteral[Convert.ToInt32(hypothese["CFLiteralDID"])]; LiteralStruct rowLiteral = new LiteralStruct(); foreach (LiteralStruct literal in literals) { if (literal.cedentType == CedentEnum.Antecedent && literal.literalIdentifier == rowLiteralId) rowLiteral = literal; } hypothesisStruct.literals = new LiteralStruct[] { rowLiteral }; quantifierSetting = new AbstractQuantifierSetting(); quantifierSetting.firstContingencyTableRows = common.GetContingecyTable(this.taskType, taskID, hypothesisID, rowLiteral.literalIdentifier, rowLiteral.literalIdentifier); quantifierSetting.secondContingencyTableRows = new int[0][]; quantifierSetting.allObjectsCount = allObjectsCount; hypothesisStruct.quantifierSetting = quantifierSetting; hypothesesResult.Add(hypothesisStruct); } result = hypothesesResult.ToArray(); }
private bool ComputeValue(AbstractQuantifierSetting setting, out double value) { TwoDimensionalContingencyTable tableA = new TwoDimensionalContingencyTable(setting.firstContingencyTableRows); tableA.StartColumnBound = ColumnFrom; tableA.StartRowBound = RowFrom; tableA.EndColumnBound = ColumnTo; tableA.EndRowBound = RowTo; TwoDimensionalContingencyTable tableB = new TwoDimensionalContingencyTable(setting.secondContingencyTableRows); tableB.StartColumnBound = ColumnFrom; tableB.StartRowBound = RowFrom; tableB.EndColumnBound = ColumnTo; tableB.EndRowBound = RowTo; if (ContingencyTable.IsOperationModeOverQuantifierValues(OperationMode)) { double valueA; bool resultA = tableA.AnyValue(Relation, Treshold, Units, setting.allObjectsCount, out valueA); double valueB; bool resultB = tableB.AnyValue(Relation, Treshold, Units, setting.allObjectsCount, out valueB); value = TwoDimensionalContingencyTable.Combine(valueA, valueB, OperationMode); if (resultA && resultB) return true; else return false; } else { TwoDimensionalContingencyTable combinedTable = ContingencyTable.Combine<TwoDimensionalContingencyTable>(tableA, tableB, OperationMode); return combinedTable.AnyValue(Relation, Treshold, Units, setting.allObjectsCount, out value); } }
/// <summary> /// Returns the relative/absolute frequency <c>a</c> from 4ft-table. /// </summary> /// <returns> /// If property <c>units</c> is set to absolute number /// returns the <c>a</c> frequency from 4ft-table. /// Else if property <c>units</c> is set to relative number /// returns the <c>a</c> frequency in percents from 4ft-table. /// </returns> public override double Value(AbstractQuantifierSetting setting, Ice.Current __current) { return ContingencyTable.Value<FourFoldContingencyTable>( FourFoldContingencyTable.BaseCeilValue, new FourFoldContingencyTable(setting.firstContingencyTableRows), Units, setting.allObjectsCount); }
public override double Value(AbstractQuantifierSetting setting, Ice.Current __current) { double value; if (ComputeValue(setting, out value)) return value; else return 0D; }
/// <summary> /// Gets the validity of the quantifier. /// </summary> /// <param name="setting">The setting.</param> /// <param name="__current">The __current.</param> /// <returns></returns> public override bool Validity(AbstractQuantifierSetting setting, Ice.Current __current) { TwoDimensionalContingencyTable table = new TwoDimensionalContingencyTable(setting.firstContingencyTableRows); table.StartColumnBound = ColumnFrom; table.StartRowBound = RowFrom; table.EndColumnBound = ColumnTo; table.EndRowBound = RowTo; double result; return table.AnyValue(Relation, Treshold, Units, setting.allObjectsCount, out result); }
/// <summary> /// Returns <c>true</c> if the statistical strength value is greater than or equal to the p parameter with the specified statistical significance (alpha). /// </summary> /// <returns><c>true</c> if if the statistical strength value is greater than or equal to the p parameter with the specified statistical significance (alpha).</returns> /// <remarks> /// <para>It computes the following condition:</para> /// <para>Sum[i = 0..a] x! / (i! * (x - i)!) * p^i * (1 - p)^(x - i) is in <c>relation</c> to alpha, /// where x = (a + b + c).</para> /// </remarks> public override bool Validity(AbstractQuantifierSetting setting, Ice.Current __current) { FourFoldContingencyTable table = new FourFoldContingencyTable(setting.firstContingencyTableRows); return table.DoubleCriticalImplicationValidity(P, Alpha, Relation); }
/// <summary> /// Gets the value of the quantifier above specified <c>setting</c>. /// </summary> /// <param name="setting">The setting.</param> /// <param name="__current">The __current.</param> /// <returns></returns> public override double Value(AbstractQuantifierSetting setting, Ice.Current __current) { TwoDimensionalContingencyTable table = new TwoDimensionalContingencyTable(setting.firstContingencyTableRows); table.StartColumnBound = ColumnFrom; table.StartRowBound = RowFrom; table.EndColumnBound = ColumnTo; table.EndRowBound = RowTo; return ContingencyTable.Value<TwoDimensionalContingencyTable>( valueFunctionDelegate, table, Units, setting.allObjectsCount); }
/// <summary> /// Gets the validity of the quantifier. /// </summary> /// <param name="setting">The setting.</param> /// <param name="__current">The __current.</param> /// <returns></returns> public override bool Validity(AbstractQuantifierSetting setting, Ice.Current __current) { return ContingencyTable.Compare(Value(setting), Relation, Treshold); }
/// <summary> /// Returns value of expression (<c>a</c> + <c>d</c>) / (<c>a</c> + <c>b</c> + <c>c</c> + <c>d</c>) from 4ft-table. /// </summary> /// <returns>The value of expression (<c>a</c> + <c>d</c>) / (<c>a</c> + <c>b</c> + <c>c</c> + <c>d</c>) 4ft-table.</returns> public override double Value(AbstractQuantifierSetting setting, Ice.Current __current) { FourFoldContingencyTable table = new FourFoldContingencyTable(setting.firstContingencyTableRows); return table.EValue(); }
/// <summary> /// The 4ft-quantifier chi-square is valid, if the null hypothesis of independence between antecedent and succedent is rejected, /// thus we say that antecedent and succedent are not independent. /// </summary> /// <returns><c>true</c> if the null hypothesis of independence is rejected.</returns> public override bool Validity(AbstractQuantifierSetting setting, Ice.Current __current) { FourFoldContingencyTable table = new FourFoldContingencyTable(setting.firstContingencyTableRows); return table.ChiSquareValidity(Alpha); }
/// <summary> /// Gets the value of the quantifier above specified <c>setting</c>. /// </summary> /// <param name="setting">The setting.</param> /// <param name="__current">The __current.</param> /// <returns></returns> public override double Value(AbstractQuantifierSetting setting, Ice.Current __current) { try { OneDimensionalContingencyTable tableA = new OneDimensionalContingencyTable(setting.firstContingencyTableRows); OneDimensionalContingencyTable tableB = new OneDimensionalContingencyTable(setting.secondContingencyTableRows); if (!useNumericValues) { return OneDimensionalContingencyTable.Value<OneDimensionalContingencyTable>( valueFunctionDelegate, tableA, tableB, OperationMode, UnitsEnum.AbsoluteNumber, 0); } else { if ( setting.numericValues == null || setting.firstContingencyTableRows[0] == null //this should never happend || setting.numericValues.Length != setting.firstContingencyTableRows[0].Length ) return 0; tableA.NumericValues = setting.numericValues; tableB.NumericValues = setting.numericValues; return ContingencyTable.Value<OneDimensionalContingencyTable>( valueFunctionDelegate, tableA, tableB, OperationMode, UnitsEnum.AbsoluteNumber, 0); } } catch (Exception e) { return 0; } }
/// <summary> /// Gets the value of the quantifier above specified <c>setting</c>. /// </summary> /// <param name="setting">The setting.</param> /// <param name="__current">The __current.</param> /// <returns></returns> public override double Value(AbstractQuantifierSetting setting, Ice.Current __current) { try { OneDimensionalContingencyTable tableA = new OneDimensionalContingencyTable(setting.firstContingencyTableRows); tableA.StartColumnBound = CategoryRangeFrom; tableA.EndColumnBound = CategoryRangeTo; OneDimensionalContingencyTable tableB = new OneDimensionalContingencyTable(setting.secondContingencyTableRows); tableB.StartColumnBound = CategoryRangeFrom; tableB.EndColumnBound = CategoryRangeTo; return ContingencyTable.Value<OneDimensionalContingencyTable>( valueFunctionDelegate, tableA, tableB, OperationMode, Units, setting.allObjectsCount); } catch (Exception e) { return 0; } }
/// <summary> /// Gets the value of the quantifier above specified <c>setting</c>. /// </summary> /// <param name="setting">The setting.</param> /// <param name="__current">The __current.</param> /// <returns></returns> public override double Value(AbstractQuantifierSetting setting, Ice.Current __current) { return ContingencyTable.Value<FourFoldContingencyTable>( valueFunctionDelegate, new FourFoldContingencyTable(setting.firstContingencyTableRows), new FourFoldContingencyTable(setting.secondContingencyTableRows), OperationMode); }
/// <summary> /// Computes the statistical strength value at the specified significance (alpha). /// </summary> /// <returns>Statistical strength value at the specified significance (alpha).</returns> /// <remarks> /// <para>Computes the numerical solution of the following equation (for variable p):</para> /// <para><c>Sum[i = 0..a] x! / (i! * (x - i)!) * p^i * (1.0 - p)^(x - i) - alpha = 0.0</c>, /// where <c>x = (a + b + c)</c>.</para> /// <para>The solution must be between 0.0 and 1.0 (inclusive).</para> /// </remarks> public override double Value(AbstractQuantifierSetting setting, Ice.Current __current) { FourFoldContingencyTable table = new FourFoldContingencyTable(setting.firstContingencyTableRows); return table.DoubleCriticalImplicationValue(Alpha); }
/// <summary> /// Gets the validity of the quantifier. /// </summary> /// <param name="setting">The setting.</param> /// <param name="__current">The __current.</param> /// <returns></returns> public override bool Validity(AbstractQuantifierSetting setting, Ice.Current __current) { double value; return ComputeValue(setting, out value); }
/// <summary> /// Gets the value of the quantifier above specified <c>setting</c>. /// </summary> /// <param name="setting">The setting.</param> /// <param name="__current">The __current.</param> /// <returns></returns> public override double Value(AbstractQuantifierSetting setting, Ice.Current __current) { OneDimensionalContingencyTable table = new OneDimensionalContingencyTable(setting.firstContingencyTableRows); table.StartColumnBound = CategoryRangeFrom; table.EndColumnBound = CategoryRangeTo; return OneDimensionalContingencyTable.Value<OneDimensionalContingencyTable>( valueFunctionDelegate, table, Units, setting.allObjectsCount); }
/// <summary> /// Returns <c>true</c> if the simple deviation strength is greater than or equal to the strength parameter. /// </summary> /// <returns><c>true</c> iff <c>(a * d) >= 2^k * (b * c)</c>.</returns> /// <remarks> /// <para>There are special cases defined explicitly:</para> /// <para>If both <c>(a * d) = 0</c> and <c>(b * c) = 0</c>, return true if <c>k <= 0</c>.</para> /// <para>If only <c>(a * d) = 0</c>, return <c>false</c>.</para> /// <para>If only <c>(b * c) = 0</c>, return <c>true</c>.</para> /// </remarks> public override bool Validity(AbstractQuantifierSetting setting, Ice.Current __current) { FourFoldContingencyTable table = new FourFoldContingencyTable(setting.firstContingencyTableRows); return table.SimpleDeviationValidity(K); }
/// <summary> /// Computes the above average strength value. /// </summary> /// <returns>Above average strength value defined as <c>(a / (a + b)) * ((a + b + c + d) / (a + c))</c> if <c>a > 0</c>; otherwise it returns zero.</returns> /// <remarks> /// <para>If a = 0, returns 0.</para> /// </remarks> public override double Value(AbstractQuantifierSetting setting, Ice.Current __current) { FourFoldContingencyTable table = new FourFoldContingencyTable(setting.firstContingencyTableRows); return FourFoldContingencyTable.AboveAverageImplicationValue(table); }
/// <summary> /// Returns <c>true</c> iff the strength is greater than or equal to the strength parameter. /// </summary> /// <returns><c>true</c> iff the strength defined as <c>(a + d) / (a + b + c + d)</c> is greater than or equal to the strength parameter.</returns> /// <remarks> /// <para>If (a + b + c + d) = 0, returns false.</para> /// </remarks> public override bool Validity(AbstractQuantifierSetting setting, Ice.Current __current) { FourFoldContingencyTable table = new FourFoldContingencyTable(setting.firstContingencyTableRows); return table.FoundedEquivalenceValidity(P); }