Skip to content

Instantly share code, notes, and snippets.

@abrudz
Created September 17, 2018 13:48
Show Gist options
  • Save abrudz/a82d3ab3705dba9f48ddd2792acd233f to your computer and use it in GitHub Desktop.
Save abrudz/a82d3ab3705dba9f48ddd2792acd233f to your computer and use it in GitHub Desktop.
Webinar file
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Arithmetic Mean\n",
"The **arithmetic mean** is the sum of a *collection* of numbers, divided by the count of numbers."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"collection←3 1 4 1 5"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To find the mean, we first find the sum."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"sum←+/collection"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Then we find the count."
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"count←≢collection"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, we divide them."
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"mean←sum÷count"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And that's the mean!"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<span style=\"white-space:pre; font-family: monospace\">2.8\n",
"</span>"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mean"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Dyalog APL",
"language": "apl",
"name": "dyalog-kernel"
},
"language_info": {
"file_extension": ".apl",
"mimetype": "text/apl",
"name": "APL"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment