Array
public extension Array where Element == Double
public extension Array where Element: Numeric
-
This is equivalent to
numpy.random.rand(count). ModuleRandomNumberGeneration.Declaration
Swift
static func random(count: Int) -> [Double]Return Value
Array of length
countinitialized with random uniform values.
-
This is equivalent to
numpy.sum(x). ModuleStatistics.Declaration
Swift
func sum( countFrom start: Element = 0 ) -> ElementParameters
countFromStarting value for the sum.
Return Value
The sum of data.
-
This is equivalent to
numpy.mean(x). ModuleStatistics.\hat\mu = {1 \over N} \sum x_iDeclaration
Swift
func mean( withStride stride: Int = 1 ) -> DoubleParameters
withStrideStride to apply.
Return Value
The arithmetic mean of data.
-
This is equivalent to
numpy.median(x). ModuleStatistics.Declaration
Swift
func median( isSorted: Bool = false, withStride stride: Int = 1 ) -> DoubleParameters
isSortedWhenewer data are already sorted.
withStrideStride to apply.
Return Value
The median of data.
-
This is equivalent to
numpy.var(x)ifwithMean = nil. ModuleStatistics.{\hat\sigma}^2 = {1 \over N} \sum (x_i - {\hat\mu})^2Declaration
Swift
func variance( withMean customMean: Double? = nil, withStride stride: Int = 1 ) -> DoubleParameters
withMeanThe mean value to compute with.
withStrideStride to apply.
Return Value
The variance of data.
-
This is equivalent to
numpy.var(x, ddof=1). ModuleStatistics.{\hat\sigma}^2 = {1 \over (N-1)} \sum (x_i - {\hat\mu})^2Declaration
Swift
func sampleVariance( withStride stride: Int = 1 ) -> DoubleParameters
withStrideStride to apply.
Return Value
The sample variance of data.
-
Module
Statistics.{\hat\sigma}^2 = {1 \over (N-1)} \sum (x_i - withMean)^2Declaration
Swift
func sampleVariance( withMean mean: Double, withStride stride: Int = 1 ) -> DoubleParameters
withMeanThe mean value to compute with.
withStrideStride to apply.
Return Value
The sample variance of data.
-
This is equivalent to
numpy.std(x)ifwithMean = nil. ModuleStatistics.Declaration
Swift
func standardDeviation( withMean customMean: Double? = nil, withStride stride: Int = 1 ) -> DoubleParameters
withMeanThe mean value to compute with.
withStrideStride to apply.
Return Value
The standard deviation of data.
-
This is equivalent to
numpy.std(x, ddof=1). ModuleStatistics.Declaration
Swift
func sampleStandardDeviation( withStride stride: Int = 1 ) -> DoubleParameters
withStrideStride to apply.
Return Value
The sample standard deviation of data.
-
Module
Statistics.Declaration
Swift
func sampleStandardDeviation( withMean mean: Double, withStride stride: Int = 1 ) -> DoubleParameters
withMeanThe mean value to compute with.
withStrideStride to apply.
Return Value
The sample standard deviation of data.
-
This is equivalent to
numpy.sum(numpy.square(numpy.subtract(data, numpy.mean(data)))). ModuleStatistics.{\rm TSS} = \sum (x_i - {\hat\mu})^2Declaration
Swift
func totalSumOfSquares( withStride stride: Int = 1 ) -> DoubleParameters
withStrideStride to apply.
Return Value
The total sum of squares of data.
-
This is equivalent to
numpy.sum(numpy.square(numpy.subtract(data, withMean))). ModuleStatistics.{\rm TSS} = \sum (x_i - withMean)^2Declaration
Swift
func totalSumOfSquares( withMean mean: Double, withStride stride: Int = 1 ) -> DoubleParameters
withMeanThe mean value to compute with.
withStrideStride to apply.
Return Value
The total sum of squares of data.
-
This is equivalent to
numpy.divide(numpy.sum(numpy.abs(numpy.subtract(data, numpy.mean(data))))), len(data)). ModuleStatistics.ad = {1 \over N} \sum |x_i - {\hat\mu}|Declaration
Swift
func absoluteDeviation( withStride stride: Int = 1 ) -> DoubleParameters
withStrideStride to apply.
Return Value
The absolute deviation from the mean of data.
-
This is equivalent to
numpy.divide(numpy.sum(numpy.abs(numpy.subtract(data, withMean))), len(data)). ModuleStatistics.ad = {1 \over N} \sum |x_i - withMean|Declaration
Swift
func absoluteDeviation( withMean mean: Double, withStride stride: Int = 1 ) -> DoubleParameters
withMeanThe mean value to compute with.
withStrideStride to apply.
Return Value
The absolute deviation from the mean of data.
-
skew = {1 \over N} \sum {\left( x_i - {\hat\mu} \over {\hat\sigma} \right)}^3
Declaration
Swift
func skew( withStride stride: Int = 1 ) -> DoubleParameters
withStrideStride to apply.
Return Value
The skewness of data.
-
skew = {1 \over N} \sum {\left( x_i - withMean \over withSampleStandardDeviation \right)}^3
Declaration
Swift
func skew( withMean mean: Double, withSampleStandardDeviation sstd: Double, withStride stride: Int = 1 ) -> DoubleParameters
withMeanThe mean value to compute with.
withSampleStandardDeviationThe std value to compute with.
withStrideStride to apply.
Return Value
The skewness of data.
-
kurtosis = \left( {1 \over N} \sum {\left(x_i - {\hat\mu} \over {\hat\sigma} \right)}^4 \right) - 3
Declaration
Swift
func kurtosis( withStride stride: Int = 1 ) -> DoubleParameters
withStrideStride to apply.
Return Value
The kurtosis of data
-
kurtosis = {1 \over N} \left( \sum {\left(x_i - withMean \over withSampleStandardDeviation \right)}^4 \right) - 3
Declaration
Swift
func kurtosis( withMean mean: Double, withSampleStandardDeviation sstd: Double, withStride stride: Int = 1 ) -> DoubleParameters
withMeanThe mean value to compute with.
withSampleStandardDeviationThe std value to compute with.
withStrideStride to apply.
Return Value
The kurtosis of data
-
a_1 = {\sum_{i = 2}^{n} (x_{i} - \hat\mu) (x_{i-1} - \hat\mu) \over \sum_{i = 1}^{n} (x_{i} - \hat\mu) (x_{i} - \hat\mu)}
Declaration
Swift
func lag1AutoCorrelation( withStride stride: Int = 1 ) -> DoubleParameters
withStrideStride to apply.
Return Value
The lag-1 autocorrelation of the dataset.
-
a_1 = {\sum_{i = 2}^{n} (x_{i} - withMean) (x_{i-1} - withMean) \over \sum_{i = 1}^{n} (x_{i} - withMean) (x_{i} - withMean)}
Declaration
Swift
func lag1AutoCorrelation( withMean mean: Double, withStride stride: Int = 1 ) -> DoubleParameters
withStrideStride to apply.
Return Value
The lag-1 autocorrelation of the dataset.
-
covar = {1 \over (n - 1)} \sum_{i = 1}^{n} (x_{i} - \hat x) (y_{i} - \hat y)
Declaration
Swift
func covariance( with data: [Double], withStride stride: Int = 1, withStride2 stride2: Int = 1 ) -> DoubleParameters
withSecond dataset to compute covariance against.
withStrideStride to apply to self.
withStride2Stride to apply to with.
Return Value
The covariance of the datasets self and with.
-
This is equivalent to
numpy.cov(self, with)[0][1].covar = {1 \over (n - 1)} \sum_{i = 1}^{n} (x_{i} - \hat x) (y_{i} - \hat y)Declaration
Swift
func covariance( with data: [Double], withMean mean: Double, withMean2 mean2: Double, withStride stride: Int = 1, withStride2 stride2: Int = 1 ) -> DoubleParameters
withSecond dataset to compute covariance against.
withMeanThe mean value of with to compute with.
withMeanThe mean value of with to compute with.
withStrideStride to apply to self.
withStride2Stride to apply to with.
Return Value
The covariance of the datasets self and with.
-
This is equivalent to
numpy.corrcoef(self, with)[0][1].r = {cov(x, y) \over \hat\sigma_x \hat\sigma_y} = {{1 \over n-1} \sum (x_i - \hat x) (y_i - \hat y) \over \sqrt{{1 \over n-1} \sum (x_i - {\hat x})^2} \sqrt{{1 \over n-1} \sum (y_i - {\hat y})^2} }Declaration
Swift
func correlation( with data: [Double], withStride stride: Int = 1, withStride2 stride2: Int = 1 ) -> DoubleParameters
withSecond dataset to compute correlation against.
withStrideStride to apply to self.
withStride2Stride to apply to with.
Return Value
The correlation of the datasets self and with.
-
This is equivalent to
scipy.stats.spearmanr(self, with).correlation.Declaration
Swift
func spearman( with data: [Double], withStride stride: Int = 1, withStride2 stride2: Int = 1 ) -> DoubleParameters
withSecond dataset to compute correlation agaisnst.
withStrideStride to apply to self.
withStride2Stride to apply to with.
Return Value
The Spearman rank correlation coefficient between the datasets self and with.
-
{\hat\mu} = {{\sum w_i x_i} \over {\sum w_i}}
Declaration
Swift
func weightedMean( weights: [Double], withWeightsStride wStride: Int = 1, withDataStride dataStride: Int = 1 ) -> DoubleParameters
weightsWeighted mean of the dataset.
withWeightsStrideStride to apply to weights.
withDataStrideStride to apply to data.
View on GitHub
Array Extension Reference