Skip to content

Instantly share code, notes, and snippets.

@wehlutyk
Created April 13, 2017 14:33
Show Gist options
  • Save wehlutyk/1061420922416853e139dea67e9726b0 to your computer and use it in GitHub Desktop.
Save wehlutyk/1061420922416853e139dea67e9726b0 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Gistr costs"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from datetime import timedelta\n",
"from urllib import request\n",
"import json\n",
"\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"TIMINGS = {\n",
" 'intro': timedelta(minutes=2, seconds=13),\n",
" 'questionnaire': timedelta(minutes=1, seconds=53),\n",
" 'back_to_exp': timedelta(seconds=13),\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"WIDTH = 50\n",
"\n",
"def pretty_print(name, value):\n",
" print(name + ': {0:>{width}}'.format(value, width=WIDTH - len(name)))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"MIN_HOURLY_RATE = 5\n",
"with request.urlopen(\"http://api.fixer.io/latest\") as f:\n",
" rates = json.load(f)\n",
" assert rates['base'] == 'EUR'\n",
" EUR_GBP = rates['rates']['GBP']\n",
"\n",
"\n",
"def currencies_str(pounds):\n",
" return \"£{:.2f} / €{:.2f}\".format(pounds, pounds / EUR_GBP)\n",
"\n",
"\n",
"def cost(n_participants, n_sentences, sentence_duration,\n",
" hourly_rate=MIN_HOURLY_RATE, print_cost=True):\n",
" if print_cost:\n",
" title = \"Cost for hourly rate {}\".format(currencies_str(hourly_rate))\n",
" print(title)\n",
" print('=' * len(title))\n",
" print('#seeds:', n_sentences)\n",
" print('#participants:', n_participants)\n",
" print('sentence duration:', '{}'.format(sentence_duration).split('.')[0])\n",
" print('-' * len(title))\n",
" \n",
" if isinstance(n_sentences, dict):\n",
" n_sentences = np.sum(list(n_sentences.values()))\n",
" duration = np.sum(list(TIMINGS.values())) + n_sentences * sentence_duration\n",
" reward = hourly_rate * duration.seconds / 3600\n",
" \n",
" participants = n_participants * reward\n",
" commission = participants * .125 + .1 * n_participants\n",
" vat = .2 * commission\n",
" total = participants + commission + vat\n",
" \n",
" if print_cost:\n",
" pretty_print(\"Participants\", \"{}\".format(currencies_str(participants)))\n",
" pretty_print(\"Commission\", \"{}\".format(currencies_str(commission)))\n",
" pretty_print(\"VAT\", \"{}\".format(currencies_str(vat)))\n",
" pretty_print(\"Total\", \"{}\".format(currencies_str(total)))\n",
" pretty_print(\"Duration\", '{}'.format(duration).split('.')[0])\n",
" pretty_print(\"Reward\", \"{}\".format(currencies_str(reward)))\n",
" \n",
" return total"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Experiment costs"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Sentence duration 1m23 (Fénéon)\n",
"\n",
"With for each seed: 7 branches, depth 10."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 10 exp seeds, 2 training seeds"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 10, 'training': 2}\n",
"#participants: 70\n",
"sentence duration: 0:01:23\n",
"----------------------------------\n",
"Participants: £122.01 / €143.82\n",
"Commission: £22.25 / €26.23\n",
"VAT: £4.45 / €5.25\n",
"Total: £148.72 / €175.29\n",
"Duration: 0:20:55\n",
"Reward: £1.74 / €2.05\n"
]
}
],
"source": [
"cost(7 * 10, {'exp': 10, 'training': 2}, sentence_duration=timedelta(minutes=1, seconds=23));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 40 exp seeds, 3 training seeds"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 40, 'training': 3}\n",
"#participants: 70\n",
"sentence duration: 0:01:23\n",
"----------------------------------\n",
"Participants: £372.17 / €438.67\n",
"Commission: £53.52 / €63.08\n",
"VAT: £10.70 / €12.62\n",
"Total: £436.39 / €514.37\n",
"Duration: 1:03:48\n",
"Reward: £5.32 / €6.27\n"
]
}
],
"source": [
"cost(7 * 10, {'exp': 40, 'training': 3}, sentence_duration=timedelta(minutes=1, seconds=23));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 2x20 exp seeds, 3 training seeds"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 20, 'training': 3}\n",
"#participants: 70\n",
"sentence duration: 0:01:23\n",
"----------------------------------\n",
"Participants: £210.78 / €248.44\n",
"Commission: £33.35 / €39.31\n",
"VAT: £6.67 / €7.86\n",
"Total: £250.79 / €295.61\n",
"Duration: 0:36:08\n",
"Reward: £3.01 / €3.55\n",
"Cost for 2 batches: €591.22\n"
]
}
],
"source": [
"total = cost(7 * 10, {'exp': 20, 'training': 3}, sentence_duration=timedelta(minutes=1, seconds=23)) * 2 / EUR_GBP\n",
"print(\"Cost for 2 batches:\", \"€{:.2f}\".format(total))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 50 exp seeds, 3 training seeds"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 50, 'training': 3}\n",
"#participants: 70\n",
"sentence duration: 0:01:23\n",
"----------------------------------\n",
"Participants: £452.86 / €533.78\n",
"Commission: £63.61 / €74.97\n",
"VAT: £12.72 / €14.99\n",
"Total: £529.19 / €623.75\n",
"Duration: 1:17:38\n",
"Reward: £6.47 / €7.63\n"
]
}
],
"source": [
"cost(7 * 10, {'exp': 50, 'training': 3}, sentence_duration=timedelta(minutes=1, seconds=23));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 2x25 exp seeds, 3 training seeds"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 25, 'training': 3}\n",
"#participants: 70\n",
"sentence duration: 0:01:23\n",
"----------------------------------\n",
"Participants: £251.12 / €296.00\n",
"Commission: £38.39 / €45.25\n",
"VAT: £7.68 / €9.05\n",
"Total: £297.19 / €350.30\n",
"Duration: 0:43:03\n",
"Reward: £3.59 / €4.23\n",
"Cost for 2 batches: €700.60\n"
]
}
],
"source": [
"total = cost(7 * 10, {'exp': 25, 'training': 3}, sentence_duration=timedelta(minutes=1, seconds=23)) * 2 / EUR_GBP\n",
"print(\"Cost for 2 batches:\", \"€{:.2f}\".format(total))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 3x17 exp seeds, 3 training seeds"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 17, 'training': 3}\n",
"#participants: 70\n",
"sentence duration: 0:01:23\n",
"----------------------------------\n",
"Participants: £186.57 / €219.91\n",
"Commission: £30.32 / €35.74\n",
"VAT: £6.06 / €7.15\n",
"Total: £222.95 / €262.79\n",
"Duration: 0:31:59\n",
"Reward: £2.67 / €3.14\n",
"Cost for 3 batches: €788.38\n"
]
}
],
"source": [
"total = cost(7 * 10, {'exp': 17, 'training': 3}, sentence_duration=timedelta(minutes=1, seconds=23)) * 3 / EUR_GBP\n",
"print(\"Cost for 3 batches:\", \"€{:.2f}\".format(total))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 60 exp seeds, 3 training seeds"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 60, 'training': 3}\n",
"#participants: 70\n",
"sentence duration: 0:01:23\n",
"----------------------------------\n",
"Participants: £533.56 / €628.90\n",
"Commission: £73.69 / €86.86\n",
"VAT: £14.74 / €17.37\n",
"Total: £621.99 / €733.13\n",
"Duration: 1:31:28\n",
"Reward: £7.62 / €8.98\n"
]
}
],
"source": [
"cost(7 * 10, {'exp': 60, 'training': 3}, sentence_duration=timedelta(minutes=1, seconds=23));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Sentence duration ~4m (Short paragraphs)\n",
"\n",
"With for each seed: 7 branches, depth 10."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 4 exp seeds, 2 training seeds"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 4, 'training': 2}\n",
"#participants: 70\n",
"sentence duration: 0:04:00\n",
"----------------------------------\n",
"Participants: £165.18 / €194.70\n",
"Commission: £27.65 / €32.59\n",
"VAT: £5.53 / €6.52\n",
"Total: £198.36 / €233.80\n",
"Duration: 0:28:19\n",
"Reward: £2.36 / €2.78\n"
]
}
],
"source": [
"cost(7 * 10, {'exp': 4, 'training': 2}, sentence_duration=timedelta(minutes=4));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 7 exp seeds, 2 training seeds"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 7, 'training': 2}\n",
"#participants: 70\n",
"sentence duration: 0:04:00\n",
"----------------------------------\n",
"Participants: £235.18 / €277.20\n",
"Commission: £36.40 / €42.90\n",
"VAT: £7.28 / €8.58\n",
"Total: £278.86 / €328.69\n",
"Duration: 0:40:19\n",
"Reward: £3.36 / €3.96\n"
]
}
],
"source": [
"cost(7 * 10, {'exp': 7, 'training': 2}, sentence_duration=timedelta(minutes=4));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 10 exp seeds, 2 training seeds"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 10, 'training': 2}\n",
"#participants: 70\n",
"sentence duration: 0:04:00\n",
"----------------------------------\n",
"Participants: £305.18 / €359.71\n",
"Commission: £45.15 / €53.21\n",
"VAT: £9.03 / €10.64\n",
"Total: £359.36 / €423.57\n",
"Duration: 0:52:19\n",
"Reward: £4.36 / €5.14\n"
]
}
],
"source": [
"cost(7 * 10, {'exp': 10, 'training': 2}, sentence_duration=timedelta(minutes=4));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Sentence duration mixed (Fénéon + Short paragraphs)\n",
"\n",
"With for each seed: 7 branches, depth 10."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 47 exp seeds, 3 training seeds, of which 43 are Fénéon and 7 are short paragraphs"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 47, 'training': 3}\n",
"#participants: 70\n",
"sentence duration: 0:01:44\n",
"----------------------------------\n",
"Participants: £535.50 / €631.19\n",
"Commission: £73.94 / €87.15\n",
"VAT: £14.79 / €17.43\n",
"Total: £624.23 / €735.77\n",
"Duration: 1:31:48\n",
"Reward: £7.65 / €9.02\n"
]
}
],
"source": [
"cost(7 * 10, {'exp': 47, 'training': 3},\n",
" sentence_duration=(43 * timedelta(minutes=1, seconds=23) + 7 * timedelta(minutes=4)) / 50);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 50 exp seeds, 3 training seeds, of which 46 are Fénéon and 7 are short paragraphs"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 50, 'training': 3}\n",
"#participants: 70\n",
"sentence duration: 0:01:43\n",
"----------------------------------\n",
"Participants: £559.61 / €659.61\n",
"Commission: £76.95 / €90.70\n",
"VAT: £15.39 / €18.14\n",
"Total: £651.95 / €768.45\n",
"Duration: 1:35:56\n",
"Reward: £7.99 / €9.42\n"
]
}
],
"source": [
"cost(7 * 10, {'exp': 50, 'training': 3},\n",
" sentence_duration=(46 * timedelta(minutes=1, seconds=23) + 7 * timedelta(minutes=4)) / 53);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"* 2x25 exp seeds, 2x3 training seeds, made of:\n",
" * 1 batch of: Exp: 22 Fénéon + 2 Mesoudi + 1 long Maxwell; Training: 3 Fénéon\n",
" * 1 batch of: Exp: 21 Fénéon + 2 Mesoudi + 1 long Maxwell + 1 short Maxwell; Training: 3 Fénéon"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cost for hourly rate £5.00 / €5.89\n",
"==================================\n",
"#seeds: {'exp': 25, 'training': 3}\n",
"#participants: 70\n",
"sentence duration: 0:01:39\n",
"----------------------------------\n",
"Participants: £296.92 / €349.97\n",
"Commission: £44.11 / €52.00\n",
"VAT: £8.82 / €10.40\n",
"Total: £349.85 / €412.37\n",
"Duration: 0:50:54\n",
"Reward: £4.24 / €5.00\n",
"Cost for 2 batches: €824.74\n"
]
}
],
"source": [
"total = cost(7 * 10, {'exp': 25, 'training': 3},\n",
" sentence_duration=(25 * timedelta(minutes=1, seconds=23) + 3 * timedelta(minutes=4)) / 28) * 2 / EUR_GBP\n",
"print(\"Cost for 2 batches:\", \"€{:.2f}\".format(total))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment