public class TMtxHypothesisTest : TMtxComponent
Encapsulates parametric and non-parametric hypothesis testing routines.
Encapsulates parametric and non-parametric hypothesis testing routines. Many problems in engineering require that we decide whether to accept or reject a statement about some parameter. The statement is called a hypothesis and the decision-making procedure about the hypothesis is called hypothesis testing.
The following hypothesis tests are supported:
- one or two sample Sign test,
- one or two sample Wilcoxon Signed-Rank test,
- one or two sample (on pooled or paired data) T test,
- one sample Z test,
- one sample ChiSquared test,
- two sample F test.
How to use TMtxHypothesisTest component?
- Drop a TMtxHypothesisTest component on the form.
- Define the hypothesis test you want to perform (Sign, Wilcoxon, Z, T, ChiSquared, F).
- Define hypothesis type (the null hypothesis type) : two, left or right tailed.
- Depending on hypothesis method define one or two sample datasets. You can do this by clicking on Dew.Stats.TMtxHypothesisTest.DataVec1 (and Dew.Stats.TMtxHypothesisTest.DataVec2) properties.
- Depending on hypothesis method you'll also have to define test mean (and in Z, F Test case sigma) property.
- Define the desired significance level Dew.Stats.TMtxHypothesisTest.Alpha.
- Call the Dew.Stats.TMtxHypothesisTest.Recalc method to calculate hypothesis test results.
Results:
- Dew.Stats.TMtxHypothesisTest.Result : The hypothesis result (accept, reject null hypothesis).
- Dew.Stats.TMtxHypothesisTest.Significance : actual significance level.
- Dew.Stats.TMtxHypothesisTest.ConfLower,Dew.Stats.TMtxHypothesisTest.ConfUpper : 100*(1-Alpha) confidence interval limits for mean (median, standard deviation).
Examples
csharp
using Dew.Stats.Units;
using Dew.Stats;
using Dew.Math;
namespace Dew.Examples
{
private void Example(TMtxHypothesis hyp)
{
hyp.Alpha = 0.03; // desired significance level at 3%
hyp.HypothesisType = THypothesisType.htTwoTailed; // two tailed => Ha= means are not equal
hyp.DataVec1.SetIt(false, new double[] { 1.0, 2.0, 3.0, 4.0 }); // first dataset
hyp.DataVec2.SetIt(false, new double[] { 1.5, 3.1, 4.2, 4.3 }); // second dataset
hyp.HypothesisMethod = THypothesisMethod.hmTTest2Pooled; // comparing means of two datasets
hyp.Recalc();
//Results ==> Significance = 0.43036618314 , Result = hrNotReject
}
}
Properties
| Name | Type | Description |
|---|---|---|
| Alpha | Double | Desired significance level. |
| AutoUpdate | Boolean | If true then changing any of the TMtxHypothesisTest properties will trigger the Dew.Stats.TMtxHypothesisTest.Recalc method. |
| BlockAssign | Boolean | Block streaming of specific properties when storing only a "template". |
| ConfLower | Double | Returns lower confidence interval limit. |
| ConfUpper | Double | Returns upper confidence interval limit. |
| DataVec1 | TVec | First sample values. |
| DataVec2 | TVec | Second sample values. |
| Dirty | Boolean | When any of the TMtxHypothesisTest properties changes, this property is automatically set to true. |
| EditorActive | Boolean | Returns True, if the component editor is displayed. |
| HypothesisMethod | THypothesisMethod | Defines which hypothesis routine will be used for data testing. |
| HypothesisType | THypothesisType | Defines hypothesis type (left, right and two-tailed). |
| Mean | Double | Defines mean/median value for one-sample test. |
| Reference | TReferenceList | Stores a list of components that have to be notified, when this component is destroyed. |
| Result | THypothesisResult | Returns hypothesis result. |
| Sigma | Double | Defines standard deviation value for single test. |
| Significance | Double | Returns calculated significance level. |
| TestStatistics | Double | Returns test statistics. |
Methods
| Name | Description |
|---|---|
| AllowStreaming | Returns the negatated value of BlockAssign. |
| Assign | Assign values of all published properties from Source. |
| AssignTemplate | Assign values of "template-like" published properties from Source. |
| EditorClass | To be overriden in descendanr classses. |
| LoadFromStream | Load the component from Src stream. |
| LoadTemplateFromFile | Load a template from file. |
| LoadTemplateFromStream | Load a template from stream. |
| Recalc | Triggers hypothesis test recalculation. |
| Reset | Reset is called after loading the data from stream or file. |
| SaveTemplateToFile | Save template to file. |
| SaveTemplateToStream | Save template to stream. |
| SaveToStream | Save the component to Dst stream. |