Files
ikcu-yzm/YZM509/nb/01_intro_statiscs.ipynb
2023-04-09 21:05:30 +03:00

145 lines
3.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"cells": [
{
"cell_type": "markdown",
"source": [
"* Mean (Ortalama)\n",
"* Median (En orta değer) (Mean of the two middle values)\n",
"* Mode: the most common value in data"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 1,
"outputs": [],
"source": [
"dizi = [37, 40, 1, 2, 3, 3, 4, 5, 15, 20, 4, 3]"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2023-04-08T23:13:37.482288Z",
"end_time": "2023-04-08T23:13:37.486971Z"
}
}
},
{
"cell_type": "code",
"execution_count": 2,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"11.416666666666666\n",
"11.416666666666666\n"
]
}
],
"source": [
"def mean1(a):\n",
" return sum(a) / float(len(a))\n",
"\n",
"import functools\n",
"def mean2(a):\n",
" return functools.reduce(lambda x, y: x + y, a) / float(len(a))\n",
"\n",
"print(mean1(dizi))\n",
"print(mean2(dizi))"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2023-04-08T23:13:37.490658Z",
"end_time": "2023-04-08T23:13:37.494548Z"
}
}
},
{
"cell_type": "code",
"execution_count": 3,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4.0\n",
"4.0\n"
]
},
{
"data": {
"text/plain": "3"
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def median(ls):\n",
" # orjinal diziyi bozmayalım diye kopyasını alalım\n",
" data = sorted(ls)\n",
"\n",
" # // --> Floor division\n",
" mid = len(data) // 2\n",
"\n",
" # ~ --> bitwise not\n",
" # https://www.w3schools.com/python/trypython.asp?filename=demo_oper_not\n",
" med = (data[mid] + data[~mid]) / 2\n",
" return med\n",
"\n",
"print(median(dizi))\n",
"\n",
"import statistics\n",
"print(statistics.median(dizi))\n",
"statistics.mode(dizi)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2023-04-08T23:13:37.495794Z",
"end_time": "2023-04-08T23:13:37.506885Z"
}
}
},
{
"cell_type": "markdown",
"source": [
"Varyans = Topla((Her terim - ortalama))^2 / n\n",
"* Varyans, verinin ortalamadan ne kadar uzaksadığının / yakınsadığının ölçüsü\n",
"* Veri örneğinin varyansı için, yine tüm değerlerin ortalaması kullanılır ama n-1'e bölünür.\n",
"\n",
"Standart Sapma = karekök(varyans)"
],
"metadata": {
"collapsed": false
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.10"
}
},
"nbformat": 4,
"nbformat_minor": 1
}