SSHypothesisTesting
public enum SSHypothesisTesting
Provides often used/needed statistical tests
-
Autocorrelation coefficient
Throws
Throws SSSwiftyStatsError.invalidArgument ifarray.count
< 2Declaration
Swift
public static func autocorrelationCoefficient<FPT>(array: Array<FPT>, lag: Int) throws -> FPT where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
array
Data
lag
Lag
Return Value
The autocorrelation coefficient for Lag
lag
-
Returns the autocorrelation coefficient for a particular lag
Throws
SSSwiftyStatsError iff data.sampleSize < 2Declaration
Swift
public static func autocorrelationCoefficient<FPT>(data: SSExamine<FPT, FPT>, lag: Int) throws -> FPT where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
SSExamine object
lag
Lag
Return Value
Autocorrelation coefficient for Lag
lag
-
Performs the Box-Ljung test for autocorrelation for all possible lags
Usage
let lew1: Array<Double> = [-213,-564,-35,-15,141,115,-420] let result: SSBoxLjungResult = try! SSHypothesisTesting.autocorrelation(data:lew1)
Throws
SSSwiftyStatsError iff data.sampleSize < 2Declaration
Swift
public static func autocorrelation<FPT>(array: Array<FPT>) throws -> SSBoxLjungResult<FPT> where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Array
Return Value
SSBoxLjungResult struct
-
Performs a Box-Ljung test for autocorrelation for all possible lags
Usage
let lew1: Array<Double> = [-213,-564,-35,-15,141,115,-420] let lewdat = SSExamine<Numeric, SSFloatingPoint>.init(withArray: lew1, characterSet: nil) let result: SSBoxLjungResult = try! SSHypothesisTesting.autocorrelation(data:lewdat)
Throws
SSSwiftyStatsError iff data.sampleSize < 2Declaration
Swift
public static func autocorrelation<FPT>(data: SSExamine<FPT, FPT>) throws -> SSBoxLjungResult<FPT> where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
SSExamine object
Return Value
SSBoxLjungResult struct
-
Performs the goodness of fit test according to Kolmogorov and Smirnov The K-S distribution is computed according to Richard Simard and Pierre L'Ecuyer (Journal of Statistical Software March 2011, Volume 39, Issue 11.)
Note
Calls ksGoFTest(data: Array
, targetDistribution target: SSGoFTarget) throws -> SSKSTestResult? Throws
SSSwiftyStatsError if data.count < 2Declaration
Swift
public static func kolmogorovSmirnovGoFTest<FPT>(array: Array<FPT>, targetDistribution target: SSGoFTarget) throws -> SSKSTestResult<FPT>? where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
array
Array
targetDistribution
Distribution to test for
Return Value
SSKSTestResul struct
-
Performs the goodness of fit test according to Kolmogorov and Smirnov The K-S distribution is computed according to Richard Simard and Pierre L'Ecuyer (Journal of Statistical Software March 2011, Volume 39, Issue 11.)
Throws
SSSwiftyStatsError if data.count < 2Declaration
Swift
public static func ksGoFTest<FPT>(array: Array<FPT>, targetDistribution target: SSGoFTarget) throws -> SSKSTestResult<FPT>? where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
array
Array
targetDistribution
Distribution to test for
Return Value
SSKSTestResul struct
-
Performs the goodness of fit test according to Kolmogorov and Smirnov. The K-S distribution is computed according to Richard Simard and Pierre L'Ecuyer (Journal of Statistical Software March 2011, Volume 39, Issue 11.)
Note
Calls ksGoFTest(data: SSExamine
, targetDistribution target: SSGoFTarget) throws -> SSKSTestResult? Throws
SSSwiftyStatsError if data.count < 2Declaration
Swift
public static func kolmogorovSmirnovGoFTest<FPT>(data: SSExamine<FPT, FPT>, targetDistribution target: SSGoFTarget) throws -> SSKSTestResult<FPT>? where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Array
targetDistribution
Distribution to test for
Return Value
SSKSTestResul struct
-
Performs the goodness of fit test according to Kolmogorov and Smirnov. The K-S distribution is computed according to Richard Simard and Pierre L'Ecuyer (Journal of Statistical Software March 2011, Volume 39, Issue 11.) This procedure returns exact p values when possible.
Throws
SSSwiftyStatsError if data.count < 2Declaration
Swift
public static func ksGoFTest<FPT>(data: SSExamine<FPT, FPT>, targetDistribution target: SSGoFTarget) throws -> SSKSTestResult<FPT>? where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
SSExamine
target
Distribution to test for
-
Performs the Anderson Darling test for normality. Adapts an algorithm originally developed by Marsaglia et al.:Evaluating the Anderson-Darling Distribution. Journal of Statistical Software 9 (2), 1–5. February 2004
Throws
SSSwiftyStatsError if data.count < 2Declaration
Swift
public static func adNormalityTest<FPT>(data: SSExamine<FPT, FPT>, alpha: FPT) throws -> SSADTestResult<FPT>? where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Data as SSExamine object
alpha
Alpha
Return Value
SSADTestResult struct.
-
Performs the Anderson Darling test for normality. Adapts an algorithm originally developed by Marsaglia et al.(Evaluating the Anderson-Darling Distribution. Journal of Statistical Software 9 (2), 1–5. February 2004)
Throws
SSSwiftyStatsError if data.count < 2Declaration
Swift
public static func adNormalityTest<FPT>(array: Array<FPT>, alpha: FPT) throws -> SSADTestResult<FPT>? where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Data
alpha
Alpha
Return Value
SSADTestResult struct.
-
Performs the Mann-Whitney U test for independent samples.
Note
If there are ties, only an asymptotic p-value is returned. Exact p-values are computed using the Algorithm by Dineen and Blakesley (1973)
Throws
SSSwiftyStatsError iff set1.sampleSize <= 2 || set2.sampleSize <= 2Declaration
Swift
public static func mannWhitneyUTest<T, FPT>(set1: Array<T>, set2: Array<T>) throws -> SSMannWhitneyUTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
set1
Observations of group1 as Array
set2
Observations of group2 as Array
Return Value
SSMannWhitneyUTestResult struct.
-
Perform the Mann-Whitney U test for independent samples.
Note
If there are ties between the sets, only an asymptotic p-value is returned. Exact p-values are computed using the Algorithm by Dineen and Blakesley (1973)
Throws
SSSwiftyStatsError iff set1.sampleSize <= 2 || set2.sampleSize <= 2Declaration
Swift
public static func mannWhitneyUTest<T, FPT>(set1: SSExamine<T, FPT>, set2: SSExamine<T, FPT>) throws -> SSMannWhitneyUTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
set1
Observations of group1
set2
Observations of group2
Return Value
SSMannWhitneyUTestResult struct.
-
Performs the Wilcoxon signed ranks test for matched pairs
Throws
SSSwiftyStatsError iff set1.count <= 2 || set1.count <= 2 || set1.count != set2.countDeclaration
Swift
public static func wilcoxonMatchedPairs<FPT>(set1: Array<FPT>, set2: Array<FPT>) throws -> SSWilcoxonMatchedPairsTestResult<FPT> where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
set1
Observations 1 as Array
set2
Observations 2 as Array
Return Value
SSWilcoxonMatchedPairsTestResult struct.
-
Performs the Wilcoxon signed ranks test for matched pairs with continuity correction (no exact p values!)
Throws
SSSwiftyStatsError iff set1.sampleSize <= 2 || set1.sampleSize <= 2 || set1.sampleSize != set2.sampleSizeDeclaration
Swift
public static func wilcoxonMatchedPairs<FPT>(set1: SSExamine<FPT, FPT>, set2: SSExamine<FPT, FPT>) throws -> SSWilcoxonMatchedPairsTestResult<FPT> where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
set1
Observations 1
set2
Observations 2
Return Value
SSWilcoxonMatchedPairsTestResult struct.
-
Performs the sign test
Throws
SSSwiftyStatsError iff set1.count <= 2 || set1.count <= 2 || set1.count != set2.countDeclaration
Swift
public static func signTest<FPT>(set1: Array<FPT>, set2: Array<FPT>) throws -> SSSignTestRestult<FPT> where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
set1
Observations 1
set2
Observations 2
Return Value
SSSignTestRestult struct
-
Performs the sign test
Throws
SSSwiftyStatsError iff set1.sampleSize <= 2 || set1.sampleSize <= 2 || set1.sampleSize != set2.sampleSizeDeclaration
Swift
public static func signTest<FPT>(set1: SSExamine<FPT, FPT>, set2: SSExamine<FPT, FPT>) throws -> SSSignTestRestult<FPT> where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
set1
Observations 1
set2
Observations 2
Return Value
SSSignTestRestult struct
-
Performs the binomial test
Note
- H0: The probability of success is equal to p0
- Ha1: the probability of success is not equal to p0 (two sided)
- Ha2: the probability of success is less than p0 (one sided)
Ha3: the probability of success is greater than p0 (one sided)
Throws
SSSwiftyStatsError iff data.sampleSize <= 2 || data.uniqueElements(sortOrder: .none)?.count)! > 2
Declaration
Swift
public static func binomialTest<FPT>(numberOfSuccess success: Int!, numberOfTrials trials: Int!, probability p0: FPT, alpha: FPT, alternative: SSAlternativeHypotheses) throws -> FPT where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Dichotomous data
p0
Probability
Return Value
p value
-
Performs the binomial test
Note
- H0: The probability of success is equal to p0
- Ha1: the probability of success is not equal to p0 (two sided)
- Ha2: the probability of success is less than p0 (one sided)
- Ha3: the probability of success is greater than p0 (one sided)
Throws
SSSwiftyStatsError iff data.sampleSize <= 2 || data.uniqueElements(sortOrder: .none)?.count)! > 2 || p0.isNaNDeclaration
Swift
public static func binomialTest<T, FPT>(data: Array<T>, characterSet: CharacterSet?, testProbability p0: FPT, successCodedAs successID: T, alpha: FPT, alternative: SSAlternativeHypotheses) throws -> SSBinomialTestResult<T, FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Dichotomous data
p0
Probability
alpha
alpha
alternative
.less, .greater or .twoSided
-
Performs the binomial test
Note
- H0: The probability of success is equal to p0
- Ha1: the probability of success is not equal to p0 (two sided)
- Ha2: the probability of success is less than p0 (one sided)
- Ha3: the probability of success is greater than p0 (one sided)
Throws
SSSwiftyStatsError iff data.sampleSize <= 2 || data.uniqueElements(sortOrder: .none)?.count)! > 2 || p0.isNaNDeclaration
Swift
public static func binomialTest<T, FPT>(data: SSExamine<T, FPT>, testProbability p0: FPT, successCodedAs successID: T, alpha: FPT, alternative: SSAlternativeHypotheses) throws -> SSBinomialTestResult<T, FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Dichotomous data
p0
Probability
alpha
alpha
alternative
.less, .greater or .twoSided
-
Performs a two sample Kolmogorov-Smirnov test.
Note
H0: The two samples are from populations with same distribution function (F1(x) = F2(x))
Ha1:(F1(x) > F2(x))
Ha2:(F1(x) < F2(x))
Throws
SSSwiftyStatsError iff set1.sampleSize <= 2 || set2.sampleSize <= 2Declaration
Swift
public static func kolmogorovSmirnovTwoSampleTest<T, FPT>(set1: Array<T>, set2: Array<T>, alpha: FPT) throws -> SSKSTwoSampleTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
set1
A Array object containg data for set 1
set2
A Array object containg data for set 2
-
Performs a two sample Kolmogorov-Smirnov test.
Note
H0: The two samples are from populations with same distribution function (F1(x) = F2(x))
Ha1:(F1(x) > F2(x))
Ha2:(F1(x) < F2(x))
Throws
SSSwiftyStatsError iff set1.sampleSize <= 2 || set2.sampleSize <= 2Declaration
Swift
public static func kolmogorovSmirnovTwoSampleTest<T, FPT>(set1: SSExamine<T, FPT>, set2: SSExamine<T, FPT>, alpha: FPT) throws -> SSKSTwoSampleTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
set1
A SSExamine object containg data for set 1
set2
A SSExamine object containg data for set 2
-
Performs the two-sided Wald Wolfowitz test for two samples
Throws
SSSwiftyStatsError iff set1.sampleSize <= 2 || set2.sampleSize <= 2Declaration
Swift
public static func waldWolfowitzTwoSampleTest<T, FPT>(set1: SSExamine<T, FPT>, set2: SSExamine<T, FPT>) throws -> SSWaldWolfowitzTwoSampleTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
set1
Observations in group 1
set2
Observations in group 2
-
Runs the Kruskal-Wallis H test. This test is a generalization of the Mann-Whitney U-test. The test checks whether all samples passed come from the same population. The H-test is distribution-independent and, like the U-test, uses the ranks of the data.
Throws
AnSSSwiftyStatsError.invalidArgument
is thrown if less than two SSExamine objects are passed or an SSExamine object has less than two elements.Declaration
Swift
public static func kruskalWallisHTest<T, FPT>(data: Array<SSExamine<T, FPT>>, alpha: FPT) throws -> SSKruskalWallisHTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
An Array of SSExamine objects
alpha
Level of significance
Return Value
A SSKruskalWallisHTestResult struct
-
Performs the Grubbs outlier test
Declaration
Swift
public static func grubbsTest<T, FPT>(array: Array<T>, alpha: FPT) throws -> SSGrubbsTestResult<T, FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
An Array
containing the data alpha
Alpha
Return Value
SSGrubbsTestResult
-
Declaration
Swift
public static func grubbsTest<T, FPT>(data: SSExamine<T, FPT>, alpha: FPT) throws -> SSGrubbsTestResult<T, FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
-
Uses the Rosner test (generalized extreme Studentized deviate = ESD test) to detect up to maxOutliers outliers. This test is more accurate than the Grubbs test (for Grubbs test the suspected number of outliers must be specified exactly.)
Declaration
Swift
public static func esdOutlierTest<T, FPT>(array: Array<T>, alpha: FPT, maxOutliers: Int!, testType: SSESDTestType) throws -> SSESDTestResult<T, FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Array
alpha
Alpha
maxOutliers
Upper bound for the number of outliers to detect
testType
SSESDTestType.lowerTail or SSESDTestType.upperTail or SSESDTestType.bothTailes (This should be default.)
-
Uses the Rosner test (generalized extreme Studentized deviate = ESD test) to detect up to maxOutliers outliers. This test is more accurate than the Grubbs test (for Grubbs test the suspected number of outliers must be specified exactly.)
Declaration
Swift
public static func esdOutlierTest<T, FPT>(data: SSExamine<T, FPT>, alpha: FPT, maxOutliers: Int!, testType: SSESDTestType) throws -> SSESDTestResult<T, FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Array
alpha
Alpha
maxOutliers
Upper bound for the number of outliers to detect
testType
SSESDTestType.lowerTail or SSESDTestType.upperTail or SSESDTestType.bothTailes (This should be default.)
-
Performs the runs test for the given sample. Tests for randomness.
Important Note
It is important that the data are numerical. To recode non-numerical data follow the procedure as described below.
- Suppose the original data is a string containing only “H” and “L”:
HLHHLHHLHLLHLHHL
- Setting “H” = 1 and “L” = 3 results in the recoded sequence:
1311311313313113
- In this case a cutting point of 2 must be used.
Setting “H” = 1 and “L” = 2 results in the recoded sequence:
1211211212212112
- In this case a cutting point of 1.5 must be used.
Throws
SSSwiftyStatsError iff data.sampleSize < 2
Declaration
Swift
public static func runsTest<FPT>(array: Array<FPT>, alpha: FPT, useCuttingPoint useCP: SSRunsTestCuttingPoint, userDefinedCuttingPoint cuttingPoint: FPT?, alternative: SSAlternativeHypotheses) throws -> SSRunsTestResult<FPT> where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Array
alpha
Alpha
useCuttingPoint
SSRunsTestCuttingPoint.median || SSRunsTestCuttingPoint.mean || SSRunsTestCuttingPoint.mode || SSRunsTestCuttingPoint.userDefined
cP
A user defined cutting point. Must not be nil if SSRunsTestCuttingPoint.userDefined is set
- Suppose the original data is a string containing only “H” and “L”:
-
Performs the runs test for the given sample. Tests for randomness.
Important Note
It is important that the data are numerical. To recode non-numerical data follow the procedure as described below.
- Suppose the original data is a string containing only “H” and “L”:
HLHHLHHLHLLHLHHL
- Setting “H” = 1 and “L” = 3 results in the recoded sequence:
1311311313313113
- In this case a cutting point of 2 must be used.
Setting “H” = 1 and “L” = 2 results in the recoded sequence:
1211211212212112
- In this case a cutting point of 1.5 must be used.
Throws
SSSwiftyStatsError iff data.sampleSize < 2
Declaration
Swift
public static func runsTest<FPT>(data: SSExamine<FPT, FPT>!, alpha: FPT, useCuttingPoint useCP: SSRunsTestCuttingPoint, userDefinedCuttingPoint cuttingPoint: FPT?, alternative: SSAlternativeHypotheses) throws -> SSRunsTestResult<FPT> where FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Array
alpha
Alpha
useCuttingPoint
SSRunsTestCuttingPoint.median || SSRunsTestCuttingPoint.mean || SSRunsTestCuttingPoint.mode || SSRunsTestCuttingPoint.userDefined
cP
A user defined cutting point. Must not be nil if SSRunsTestCuttingPoint.userDefined is set
- Suppose the original data is a string containing only “H” and “L”:
-
Performs the two sample t test
Throws
SSSwiftyStatsError iff sample1.sampleSize < 2 || sample2.sampleSize < 2Declaration
Swift
public static func twoSampleTTest<T, FPT>(data1: Array<T>, data2: Array<T>, alpha: FPT) throws -> SS2SampleTTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
sample1
Data1 as Array
sample2
Data2 as Array
alpha
Alpha
-
Performs the two sample t test
Throws
SSSwiftyStatsError iff sample1.sampleSize < 2 || sample2.sampleSize < 2Declaration
Swift
public static func twoSampleTTest<T, FPT>(sample1: SSExamine<T, FPT>!, sample2: SSExamine<T, FPT>, alpha: FPT) throws -> SS2SampleTTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
sample1
Data1 as SSExamine
sample2
Data2 as SSExamine
alpha
Alpha
-
Performs the one sample t test
Throws
SSSwiftyStatsError iff sample.sampleSize < 2Declaration
Swift
public static func oneSampleTTest<T, FPT>(sample: SSExamine<T, FPT>, mean: FPT, alpha: FPT) throws -> SSOneSampleTTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
sample
Data as SSExamine
mean
Reference mean
alpha
Alpha
-
Performs the one sample t test
Throws
SSSwiftyStatsError iff sample.sampleSize < 2Declaration
Swift
public static func oneSampleTTEst<T, FPT>(data: Array<T>, mean: FPT, alpha: FPT) throws -> SSOneSampleTTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Data as Array
mean
Reference mean
alpha
Alpha
-
Performs the t test for matched pairs
Throws
SSSwiftyStatsError iff set1.sampleSize < 2 || set2.sampleSize < 2 || (set1.sampleSize != set2.sampleSize)Declaration
Swift
public static func matchedPairsTTest<T, FPT>(set1: SSExamine<T, FPT>!, set2: SSExamine<T, FPT>, alpha: FPT) throws -> SSMatchedPairsTTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
set1
data of set1 as SSExamine
set2
data of set2 as SSExamine
alpha
Alpha
-
Performs the t test for matched pairs
Throws
SSSwiftyStatsError iff data1.count < 2 || data2.count < 2 || data1.count != data2.countDeclaration
Swift
public static func matchedPairsTTest<T, FPT>(data1: Array<T>, data2: Array<T>, alpha: FPT) throws -> SSMatchedPairsTTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
set1
data of set1 as Array
set2
data of set2 as Array
alpha
Alpha
-
Performs a one way ANOVA (multiple means test)
Throws
SSSwiftyStatsError iff data.count <= 2Declaration
Swift
public static func oneWayANOVA<T, FPT>(data: Array<Array<T>>!, alpha: FPT) throws -> SSOneWayANOVATestResult<FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
data as Array
alpha
Alpha
-
Performs a one way ANOVA (multiple means test)
Throws
SSSwiftyStatsError iff data.count <= 2Declaration
Swift
public static func oneWayANOVA<T, FPT>(data: Array<SSExamine<T, FPT>>!, alpha: FPT) throws -> SSOneWayANOVATestResult<FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
data as SSExamine
alpha
Alpha
-
Performs a one way ANOVA (multiple means test)
Throws
SSSwiftyStatsError.invalidArgument iff data.count <= 2Declaration
Swift
public static func oneWayANOVA<T, FPT>(dataFrame: SSDataFrame<T, FPT>, alpha: FPT) throws -> SSOneWayANOVATestResult<FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
dataFrame
data as SSDataFrame
alpha
Alpha
-
Performs a one way ANOVA (multiple means test) same as oneWayAnova(:,:)
Throws
SSSwiftyStatsError.invalidArgument iff data.count <= 2Declaration
Swift
public static func multipleMeansTest<T, FPT>(dataFrame: SSDataFrame<T, FPT>, alpha: FPT) throws -> SSOneWayANOVATestResult<FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
dataFrame
data as SSDataFrame
alpha
Alpha
-
Performs a one way ANOVA (multiple means test) same as oneWayAnova(:,:)
Throws
SSSwiftyStatsError iff data.count <= 2Declaration
Swift
public static func multipleMeansTest<T, FPT>(data: Array<Array<T>>!, alpha: FPT) throws -> SSOneWayANOVATestResult<FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
data as Array
alpha
Alpha
-
Performs a one way ANOVA (multiple means test) same as oneWayAnova(:,:)
Throws
SSSwiftyStatsError iff data.count <= 2Declaration
Swift
public static func multipleMeansTest<T, FPT>(data: Array<SSExamine<T, FPT>>!, alpha: FPT) throws -> SSOneWayANOVATestResult<FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
data as SSExamine
alpha
Alpha
-
Performs the Tukey-Kramer test for multiple comparisons
Structure of the differences array:
m(0) m(1) m(2) m(3) ... m(k - 1)
m(0) - d(0,1) d(0,2) m(0,3) … d(0,k - 1) m(1) d(1,0) - d(1,2) m(1,3) … d(1,k - 1) m(2) d(2,0) d(2,1) - m(2,3) … d(2,k - 1) m(3) d(3,0) d(3,1) - - … d(3,k - 1) . . . . . … d(2,k - 1) . . . . . … . m(k - 1) d(k - 1,0) d(k - 1,1) d(k - 1,2) d(k - 1,3) … -
Structure of the T array:
m(0) m(1) m(2) ... m(k - 1)
m(0) - T(0,1) T(0,2) … T(0,k - 1) m(1) T(1,0) - T(1,2) … T(1,k - 1) m(2) T(2,0) T(2,1) - … T(2,k - 1) . . . . … . . . . . … . . . . . … . m(k - 1) T(k - 1,0) T(k - 1,1) T(k - 1,2) … -
Throws
SSSwiftyStatsError.invalidArgument iff data.count <= 2Precondition
Each examine object should be named uniquely.Declaration
Swift
public static func tukeyKramerTest<T, FPT>(dataFrame: SSDataFrame<T, FPT>, alpha: FPT) throws -> Array<SSPostHocTestResult<FPT>>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
data as SSDataFrame
alpha
Alpha
Return Value
SSHSDResultRow
-
Performs the Tukey-Kramer test for multiple comparisons
Throws
SSSwiftyStatsError.invalidArgument iff data.count <= 2Precondition
Each examine object should be named uniquely.Declaration
Swift
public static func tukeyKramerTest<T, FPT>(data: Array<SSExamine<T, FPT>>, alpha: FPT) throws -> Array<SSPostHocTestResult<FPT>>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
data as SSExamine
alpha
Alpha
Return Value
SSHSDResultRow
-
Performs the post hoc test according to Scheffé
Throws
SSSwiftyStatsError.invalidArgument iff data.count <= 2Declaration
Swift
public static func scheffeTest<T, FPT>(dataFrame: SSDataFrame<T, FPT>, alpha: FPT) throws -> Array<SSPostHocTestResult<FPT>>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
dataFrame
Data as SSDataFrame
alpha
Alpha
Return Value
A SSPostHocTestResult struct
-
Undocumented
Declaration
Swift
public static func bonferroniTest<T, FPT>(dataFrame: SSDataFrame<T, FPT>) throws -> Array<SSPostHocTestResult<FPT>>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
-
Performs the Bartlett test for two or more samples
Throws
SSSwiftyStatsError if data.count < 2 or no variances are obtainableDeclaration
Swift
public static func bartlettTest<T, FPT>(data: Array<SSExamine<T, FPT>>, alpha: FPT) throws -> SSVarianceEqualityTestResult<FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Array containing samples as SSExamine objects
alpha
Alpha
-
Performs the Bartlett test for two or more samples
Throws
SSSwiftyStatsError if data.count < 2 or no variances are obtainableDeclaration
Swift
public static func bartlettTest<T, FPT>(array: Array<Array<T>>, alpha: FPT) throws -> SSVarianceEqualityTestResult<FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Array containing samples
alpha
Alpha
-
Performs the Levene / Brown-Forsythe test for two or more samples
Throws
SSSwiftyStatsError if data.count < 2 or no variances are obtainableDeclaration
Swift
public static func leveneTest<T, FPT>(data: Array<SSExamine<T, FPT>>!, testType: SSLeveneTestType, alpha: FPT) throws -> SSVarianceEqualityTestResult<FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Array containing SSExamine objects
testType
.median (Brown-Forsythe test), .mean (Levene test), .trimmedMean (10% trimmed mean)
alpha
Alpha
-
Performs the Levene / Brown-Forsythe test for two or more samples
Throws
SSSwiftyStatsError if data.count < 2 or no variances are obtainableDeclaration
Swift
public static func leveneTest<T, FPT>(array: Array<Array<T>>!, testType: SSLeveneTestType, alpha: FPT) throws -> SSVarianceEqualityTestResult<FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Array containing samples
testType
.median (Brown-Forsythe test), .mean (Levene test), .trimmedMean (10% trimmed mean)
alpha
Alpha
-
Performs the Chi^2 variance equality test
Throws
SSSwiftyStatsError if data.sampleSize < 2 || s0 <= 0Declaration
Swift
public static func chiSquareVarianceTest<T, FPT>(array: Array<T>, nominalVariance s0: FPT, alpha: FPT) throws -> SSChiSquareVarianceTestResult<FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data
Data as Array
s0
nominal variance
alpha
Alpha
-
Performs the Chi^2 variance equality test
Throws
SSSwiftyStatsError if sample.sampleSize < 2 || s0 <= 0Declaration
Swift
public static func chiSquareVarianceTest<T, FPT>(sample: SSExamine<T, FPT>, nominalVariance s0: FPT, alpha: FPT) throws -> SSChiSquareVarianceTestResult<FPT>? where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
sample
Data as SSExamine
s0
nominal variance
alpha
Alpha
-
Performs the F ratio test for variance equality
Throws
SSSwiftyStatsError iff data1.sampleSize < 2 || data1.sampleSize < 2Declaration
Swift
public static func fTestVarianceEquality<T, FPT>(data1: Array<T>, data2: Array<T>, alpha: FPT) throws -> SSFTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
data1
Data as Array
data1
Data as Array
alpha
Alpha
-
Performs the F ratio test for variance equality
Throws
SSSwiftyStatsError iff sample1.sampleSize < 2 || sample1.sampleSize < 2Declaration
Swift
public static func fTestVarianceEquality<T, FPT>(sample1: SSExamine<T, FPT>, sample2: SSExamine<T, FPT>, alpha: FPT) throws -> SSFTestResult<FPT> where T : Comparable, T : Decodable, T : Encodable, T : Hashable, FPT : Decodable, FPT : Encodable, FPT : SSFloatingPoint
Parameters
sample1
Data as SSExamine
sample2
Data as SSExamine
alpha
Alpha