Files
ikcu-yzm/YZM509/nb/01_intro_statiscs.ipynb
2023-04-04 12:33:38 +03:00

107 lines
2.4 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": null,
"outputs": [],
"source": [
"dizi = [37, 40, 1, 2, 3, 3, 4, 5, 15, 20, 4, 3]"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"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
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"def median(ls):\n",
" # orjinla diziyi bozmayalım diye kopyasını alallı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
}
},
{
"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
}