You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Explore a world of data structures in Swift. Learn how to use data structures to organize, analyze, and manipulate data.
5
+
Algorithm is a collection of data structures that are empowered by a probability toolset.
6
+
7
+
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.
6
8
7
9
## Requirements
8
10
9
11
* iOS 8.0+ / Mac OS X 10.9+
10
-
* Xcode 7.2+
12
+
* Xcode 7.3+
11
13
12
14
## Communication
13
15
@@ -31,6 +33,7 @@ Algorithm is a growing project and will encounter changes throughout its develop
31
33
## A Tour
32
34
33
35
*[Probability](#probability)
36
+
*[ExpectedValue](#expectedvalue)
34
37
*[DoublyLinkedList](#doublylinkedlist)
35
38
*[Stack](#stack)
36
39
*[Queue](#queue)
@@ -44,23 +47,20 @@ Algorithm is a growing project and will encounter changes throughout its develop
44
47
<aname="probability"></a>
45
48
## Probability
46
49
47
-
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:
50
+
Each data structure within Algorithm is equipped with probability tools.
51
+
52
+
#### Basic Probability
48
53
49
-
Determining the probability of rolling a 3 using a die of 6 numbers.
54
+
For example, determining the probability of rolling a 3 using a die of 6 numbers.
50
55
51
56
```swift
52
57
let die: Array<Int> =Array<Int>(arrayLiteral: 1, 2, 3, 4, 5, 6)
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.
63
+
For conditional probabilities that require a more complex calculation, use block statements.
64
64
65
65
```swift
66
66
let die: Array<Int> =Array<Int>(arrayLiteral: 1, 2, 3, 4, 5, 6)
@@ -78,6 +78,16 @@ if 0.33 < probabilityOfX {
78
78
}
79
79
```
80
80
81
+
<aname="expectedvalue"></a>
82
+
## Expected Value
83
+
84
+
The expected value of rolling a 3 or 6 with 100 trials using a die of 6 numbers.
85
+
86
+
```swift
87
+
let die: Array<Int> =Array<Int>(arrayLiteral: 1, 2, 3, 4, 5, 6)
0 commit comments