Fossil SCM

Polishing pass on www/collisions.ipynb: improved docs, simplified the "sd" parameter as "spread", removed an empty cell, and renumbered the cells.

wyoung 2019-06-16 20:16 trunk
Commit 847423edfaae1dd2d9baa767b95194f12cc700c94b595ba8f3372a73d7b158d7
1 file changed +28 -26
--- www/collisions.ipynb
+++ www/collisions.ipynb
@@ -2,11 +2,11 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7
- "Pull in the packages we need"
7
+ "*Pull in the packages we need:*"
88
]
99
},
1010
{
1111
"cell_type": "code",
1212
"execution_count": 1,
@@ -25,50 +25,52 @@
2525
"* **cpd** - Checkins per day. Defaults to 20.\n",
2626
"\n",
2727
"* **days** - Number of days to simulate. Defaults to 10000, or roughly\n",
2828
" 40 working years.\n",
2929
"\n",
30
- "* **winSz** - Size of the commit window in percentage of the working day.\n",
31
- " Defaults to 0.01% with the default for workSec, which is roughly 3\n",
32
- " seconds with the default `workSec` value, a long-ish commit time for Fossil.\n",
30
+ "* **winSz** - Size of the commit window as a fraction of `workSec`. Defaults\n",
31
+ " to 0.01%, which is roughly 3 seconds for the default 8-hour work day, a\n",
32
+ " a long-ish commit time for Fossil.\n",
3333
"\n",
3434
"* **workSec** - Seconds in working day, defaulting to 8 hours. This value\n",
3535
" only affects the reporting output, not the results of the underlying\n",
3636
" simulation. It's a scaling parameter to humanize the results.\n",
3737
" \n",
38
- "* **sd** - The standard deviation to use for our normally-distributed random\n",
39
- " numbers. The default gives \"nice\" distributions, spread over the working\n",
40
- " day with a low chance of generating values outside the working day.\n",
41
- " \n",
42
- " The larger this value gets, the more spread out the checkins, and so the\n",
43
- " lower the chance of collisions. You might want to increase it a bit to\n",
44
- " simulate early and late workers. (e.g. `workSec / 3`)\n",
45
- " \n",
46
- " As you decrease this value — e.g. `workSec / 5` — you're simulating a work\n",
47
- " environment where people tend to check their work in closer and closer\n",
48
- " to mid-day, which increases the chance of collision.\n"
38
+ "* **spread** - Adjustment factor in computing the standard deviation for our \n",
39
+ " normally-distributed random numbers. The default gives \"nice\" distributions,\n",
40
+ " spread over the working day with a low chance of generating values outside\n",
41
+ " the working day.\n",
42
+ " \n",
43
+ " The smaller this value gets (<4), the more spread out the checkins, and\n",
44
+ " so the lower the chance of collisions. You might want to decrease it a bit\n",
45
+ " to simulate early and late workers.\n",
46
+ " \n",
47
+ " As you increase this value (>4) you're simulating a work environment\n",
48
+ " where people tend to check their work in closer and closer to mid-day,\n",
49
+ " which increases the chance of collision."
4950
]
5051
},
5152
{
5253
"cell_type": "code",
53
- "execution_count": 8,
54
+ "execution_count": 2,
5455
"metadata": {},
5556
"outputs": [],
5657
"source": [
5758
"collisions <- function(\n",
5859
" cpd = 20,\n",
5960
" days = 10000,\n",
6061
" winSz = 0.01 / 100,\n",
6162
" workSec = 8 * 60 * 60,\n",
62
- " sd = workSec / 4)\n",
63
+ " spread = 4)\n",
6364
"{\n",
6465
" cat(\"Running simulation...\\n\")\n",
6566
"\n",
6667
" day = 0\n",
6768
" collisions = 0\n",
6869
" winSec = workSec * winSz\n",
6970
" mean = workSec / 2\n",
71
+ " sd = workSec / spread\n",
7072
"\n",
7173
" while (day < days) {\n",
7274
" # Create the commit time vector as random values in a normal\n",
7375
" # distribution.\n",
7476
" times = sort(rnorm(cpd, mean, sd))\n",
@@ -89,34 +91,34 @@
8991
" cat(\"Found\", collisions, \"collisions in\", days, (workSec / 3600),\n",
9092
" \"hour working days with\", winSec, \"second windows.\\n\")\n",
9193
"}"
9294
]
9395
},
96
+ {
97
+ "cell_type": "markdown",
98
+ "metadata": {},
99
+ "source": [
100
+ "*Run the following cell, possibly changing parameters documented above:*"
101
+ ]
102
+ },
94103
{
95104
"cell_type": "code",
96
- "execution_count": 10,
105
+ "execution_count": 3,
97106
"metadata": {},
98107
"outputs": [
99108
{
100109
"name": "stdout",
101110
"output_type": "stream",
102111
"text": [
103112
"Running simulation...\n",
104
- "Found 423 collisions in 10000 8 hour working days with 2.88 second windows.\n"
113
+ "Found 422 collisions in 10000 8 hour working days with 2.88 second windows.\n"
105114
]
106115
}
107116
],
108117
"source": [
109118
"collisions()"
110119
]
111
- },
112
- {
113
- "cell_type": "code",
114
- "execution_count": null,
115
- "metadata": {},
116
- "outputs": [],
117
- "source": []
118120
}
119121
],
120122
"metadata": {
121123
"kernelspec": {
122124
"display_name": "R",
123125
--- www/collisions.ipynb
+++ www/collisions.ipynb
@@ -2,11 +2,11 @@
2 "cells": [
3 {
4 "cell_type": "markdown",
5 "metadata": {},
6 "source": [
7 "Pull in the packages we need"
8 ]
9 },
10 {
11 "cell_type": "code",
12 "execution_count": 1,
@@ -25,50 +25,52 @@
25 "* **cpd** - Checkins per day. Defaults to 20.\n",
26 "\n",
27 "* **days** - Number of days to simulate. Defaults to 10000, or roughly\n",
28 " 40 working years.\n",
29 "\n",
30 "* **winSz** - Size of the commit window in percentage of the working day.\n",
31 " Defaults to 0.01% with the default for workSec, which is roughly 3\n",
32 " seconds with the default `workSec` value, a long-ish commit time for Fossil.\n",
33 "\n",
34 "* **workSec** - Seconds in working day, defaulting to 8 hours. This value\n",
35 " only affects the reporting output, not the results of the underlying\n",
36 " simulation. It's a scaling parameter to humanize the results.\n",
37 " \n",
38 "* **sd** - The standard deviation to use for our normally-distributed random\n",
39 " numbers. The default gives \"nice\" distributions, spread over the working\n",
40 " day with a low chance of generating values outside the working day.\n",
41 " \n",
42 " The larger this value gets, the more spread out the checkins, and so the\n",
43 " lower the chance of collisions. You might want to increase it a bit to\n",
44 " simulate early and late workers. (e.g. `workSec / 3`)\n",
45 " \n",
46 " As you decrease this value — e.g. `workSec / 5` — you're simulating a work\n",
47 " environment where people tend to check their work in closer and closer\n",
48 " to mid-day, which increases the chance of collision.\n"
 
49 ]
50 },
51 {
52 "cell_type": "code",
53 "execution_count": 8,
54 "metadata": {},
55 "outputs": [],
56 "source": [
57 "collisions <- function(\n",
58 " cpd = 20,\n",
59 " days = 10000,\n",
60 " winSz = 0.01 / 100,\n",
61 " workSec = 8 * 60 * 60,\n",
62 " sd = workSec / 4)\n",
63 "{\n",
64 " cat(\"Running simulation...\\n\")\n",
65 "\n",
66 " day = 0\n",
67 " collisions = 0\n",
68 " winSec = workSec * winSz\n",
69 " mean = workSec / 2\n",
 
70 "\n",
71 " while (day < days) {\n",
72 " # Create the commit time vector as random values in a normal\n",
73 " # distribution.\n",
74 " times = sort(rnorm(cpd, mean, sd))\n",
@@ -89,34 +91,34 @@
89 " cat(\"Found\", collisions, \"collisions in\", days, (workSec / 3600),\n",
90 " \"hour working days with\", winSec, \"second windows.\\n\")\n",
91 "}"
92 ]
93 },
 
 
 
 
 
 
 
94 {
95 "cell_type": "code",
96 "execution_count": 10,
97 "metadata": {},
98 "outputs": [
99 {
100 "name": "stdout",
101 "output_type": "stream",
102 "text": [
103 "Running simulation...\n",
104 "Found 423 collisions in 10000 8 hour working days with 2.88 second windows.\n"
105 ]
106 }
107 ],
108 "source": [
109 "collisions()"
110 ]
111 },
112 {
113 "cell_type": "code",
114 "execution_count": null,
115 "metadata": {},
116 "outputs": [],
117 "source": []
118 }
119 ],
120 "metadata": {
121 "kernelspec": {
122 "display_name": "R",
123
--- www/collisions.ipynb
+++ www/collisions.ipynb
@@ -2,11 +2,11 @@
2 "cells": [
3 {
4 "cell_type": "markdown",
5 "metadata": {},
6 "source": [
7 "*Pull in the packages we need:*"
8 ]
9 },
10 {
11 "cell_type": "code",
12 "execution_count": 1,
@@ -25,50 +25,52 @@
25 "* **cpd** - Checkins per day. Defaults to 20.\n",
26 "\n",
27 "* **days** - Number of days to simulate. Defaults to 10000, or roughly\n",
28 " 40 working years.\n",
29 "\n",
30 "* **winSz** - Size of the commit window as a fraction of `workSec`. Defaults\n",
31 " to 0.01%, which is roughly 3 seconds for the default 8-hour work day, a\n",
32 " a long-ish commit time for Fossil.\n",
33 "\n",
34 "* **workSec** - Seconds in working day, defaulting to 8 hours. This value\n",
35 " only affects the reporting output, not the results of the underlying\n",
36 " simulation. It's a scaling parameter to humanize the results.\n",
37 " \n",
38 "* **spread** - Adjustment factor in computing the standard deviation for our \n",
39 " normally-distributed random numbers. The default gives \"nice\" distributions,\n",
40 " spread over the working day with a low chance of generating values outside\n",
41 " the working day.\n",
42 " \n",
43 " The smaller this value gets (&lt;4), the more spread out the checkins, and\n",
44 " so the lower the chance of collisions. You might want to decrease it a bit\n",
45 " to simulate early and late workers.\n",
46 " \n",
47 " As you increase this value (&gt;4) you're simulating a work environment\n",
48 " where people tend to check their work in closer and closer to mid-day,\n",
49 " which increases the chance of collision."
50 ]
51 },
52 {
53 "cell_type": "code",
54 "execution_count": 2,
55 "metadata": {},
56 "outputs": [],
57 "source": [
58 "collisions <- function(\n",
59 " cpd = 20,\n",
60 " days = 10000,\n",
61 " winSz = 0.01 / 100,\n",
62 " workSec = 8 * 60 * 60,\n",
63 " spread = 4)\n",
64 "{\n",
65 " cat(\"Running simulation...\\n\")\n",
66 "\n",
67 " day = 0\n",
68 " collisions = 0\n",
69 " winSec = workSec * winSz\n",
70 " mean = workSec / 2\n",
71 " sd = workSec / spread\n",
72 "\n",
73 " while (day < days) {\n",
74 " # Create the commit time vector as random values in a normal\n",
75 " # distribution.\n",
76 " times = sort(rnorm(cpd, mean, sd))\n",
@@ -89,34 +91,34 @@
91 " cat(\"Found\", collisions, \"collisions in\", days, (workSec / 3600),\n",
92 " \"hour working days with\", winSec, \"second windows.\\n\")\n",
93 "}"
94 ]
95 },
96 {
97 "cell_type": "markdown",
98 "metadata": {},
99 "source": [
100 "*Run the following cell, possibly changing parameters documented above:*"
101 ]
102 },
103 {
104 "cell_type": "code",
105 "execution_count": 3,
106 "metadata": {},
107 "outputs": [
108 {
109 "name": "stdout",
110 "output_type": "stream",
111 "text": [
112 "Running simulation...\n",
113 "Found 422 collisions in 10000 8 hour working days with 2.88 second windows.\n"
114 ]
115 }
116 ],
117 "source": [
118 "collisions()"
119 ]
 
 
 
 
 
 
 
120 }
121 ],
122 "metadata": {
123 "kernelspec": {
124 "display_name": "R",
125

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button