diff --git a/Algorithm.podspec b/Algorithm.podspec index 7099f5a..8dbe19e 100644 --- a/Algorithm.podspec +++ b/Algorithm.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'Algorithm' - s.version = '1.0.7' - s.license = 'BSD' + s.version = '1.0.8' + s.license = 'BSD-3-Clause' s.summary = 'A toolset for writing algorithms in Swift.' s.homepage = 'http://cosmicmind.io' s.social_media_url = 'https://www.facebook.com/graphkit' diff --git a/README.md b/README.md index 161f3fd..c5c3e2b 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,15 @@ -![CosmicMind](http://www.cosmicmind.io/CM/CosmicMind.png) +![CosmicMind](http://www.cosmicmind.io/algorithm/index/images/AlgorithmIcon.png) ## Welcome to Algorithm -Explore a world of data structures in Swift. Learn how to use data structures to organize, analyze, and manipulate data. +Algorithm is a collection of data structures that are empowered by a probability toolset. + +Algorithm's architecture is designed for beginners and professionals. Its robust API requires no setup and is ready for the simplest and most extensive applications. ## Requirements * iOS 8.0+ / Mac OS X 10.9+ -* Xcode 7.2+ +* Xcode 7.3+ ## Communication @@ -31,6 +33,7 @@ Algorithm is a growing project and will encounter changes throughout its develop ## A Tour * [Probability](#probability) +* [ExpectedValue](#expectedvalue) * [DoublyLinkedList](#doublylinkedlist) * [Stack](#stack) * [Queue](#queue) @@ -44,23 +47,20 @@ Algorithm is a growing project and will encounter changes throughout its develop ## Probability -Probability is a core feature. Your application may be completely catered to your users' habits and usage. To demonstrate this wonderful feature, let's look at some examples: +Each data structure within Algorithm is equipped with probability tools. + +#### Basic Probability -Determining the probability of rolling a 3 using a die of 6 numbers. +For example, determining the probability of rolling a 3 using a die of 6 numbers. ```swift let die: Array = Array(arrayLiteral: 1, 2, 3, 4, 5, 6) print(die.probabilityOf(3)) // Output: 0.166666666666667 ``` -The expected value of rolling a 3 or 6 with 100 trials using a die of 6 numbers. - -```swift -let die: Array = Array(arrayLiteral: 1, 2, 3, 4, 5, 6) -print(die.expectedValueOf(100, elements: 3, 6)) // Output: 33.3333333333333 -``` +#### Conditional Probability -The above examples are quite simple. They use basic calculations to determine the probability of an outcome (X). What if you have a complicated condition? To solve this problem, it is possible to pass in blocks that return a boolean value. Each block may execute any operations it pleases, so long as it returns a "true" or "false". The "true" values contribute to the likelihood of an outcome, "false" results do not. Below is an example to demonstrate this feature. +For conditional probabilities that require a more complex calculation, use block statements. ```swift let die: Array = Array(arrayLiteral: 1, 2, 3, 4, 5, 6) @@ -78,6 +78,16 @@ if 0.33 < probabilityOfX { } ``` + +## Expected Value + +The expected value of rolling a 3 or 6 with 100 trials using a die of 6 numbers. + +```swift +let die: Array = Array(arrayLiteral: 1, 2, 3, 4, 5, 6) +print(die.expectedValueOf(100, elements: 3, 6)) // Output: 33.3333333333333 +``` + ## DoublyLinkedList diff --git a/Sources/Info.plist b/Sources/Info.plist index 81c339a..a70ac6a 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.7 + 1.0.8 CFBundleSignature ???? CFBundleVersion