SigmaSwiftStatistics Documentation
Welcome to the official documentation for SigmaSwiftStatistics – a Swift library providing statistical functions and algorithms. This documentation serves as a comprehensive guide for understanding and utilizing the features offered by the library. Whether you are a beginner or an experienced developer, this documentation will help you get started and dive deeper into the world of statistical analysis using SigmaSwiftStatistics.
Installation
To use SigmaSwiftStatistics in your Swift project, you need to add it as a dependency. There are two options:
Option 1: Cocoapods
- Open your project directory in Terminal.
- Create a
Podfile
by runningpod init
. - Add the following line to your
Podfile
:pod 'SigmaSwiftStatistics'
. - Save the file and run
pod install
in Terminal to install the library. - Import SigmaSwiftStatistics in your Swift file using
import SigmaSwiftStatistics
.
Option 2: Swift Package Manager
- In Xcode, go to File > Swift Packages > Add Package Dependency.
- Enter the URL of this repository (
https://github.com/yourusername/SigmaSwiftStatistics.git
) and click Next. - Choose the branch or version rule you want to use and click Next.
- Ensure the library is checked and click Finish.
- Import SigmaSwiftStatistics in your Swift file using
import SigmaSwiftStatistics
.
Features
Mean Calculation
The library provides functions to calculate the mean (average) of a given array or sequence of numbers. It supports both weighted and unweighted mean calculations.
To calculate the mean:
- Use the
mean()
function for unweighted mean calculations. - Use the
weightedMean()
function for weighted mean calculations, where each element has a corresponding weight.
Example:
“`swift
let numbers = [1, 2, 3, 4, 5]
let unweightedMean = mean(numbers)
let weightedMean = weightedMean(numbers, weights: [1, 1, 2, 2, 2])
“`
Median Calculation
The library provides functions to calculate the median of a given array or sequence of numbers. It supports both ungrouped and grouped median calculations.
To calculate the median:
- Use the
median()
function for ungrouped median calculations. - Use the
groupedMedian()
function for grouped median calculations, where each element has a corresponding frequency.
Example:
“`swift
let numbers = [1, 2, 3, 4, 5]
let ungroupedMedian = median(numbers)
let groupedMedian = groupedMedian([1, 2, 3, 4, 5], frequencies: [3, 1, 2, 1, 1])
“`
Variance Calculation
The library provides functions to calculate the variance and standard deviation of a given array or sequence of numbers.
- Use the
variance()
function for variance calculations. - Use the
standardDeviation()
function for standard deviation calculations.
Example:
“`swift
let numbers = [1, 2, 3, 4, 5]
let variance = variance(numbers)
let standardDeviation = standardDeviation(numbers)
“`
Additional Statistical Functions
SigmaSwiftStatistics library provides various additional statistical functions, including:
skewness()
: Calculates the skewness of a given array or sequence of numbers.kurtosis()
: Calculates the kurtosis of a given array or sequence of numbers.covariance()
: Calculates the covariance between two arrays or sequences of numbers.correlation()
: Calculates the correlation coefficient between two arrays or sequences of numbers.percentile()
: Calculates the value at a specified percentile in a given array or sequence of numbers.- And more…
Refer to the full API documentation for complete details and usage examples of these functions.
Conclusion
Congratulations! You have now learned the basics of SigmaSwiftStatistics and how to perform statistical calculations using the library. Feel free to explore the other functions and experiment with different datasets to gain a deeper understanding of statistical analysis possibilities. For more details and examples, please refer to the comprehensive API documentation.