{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数学函数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **将数组a中大于30的值替换为30，小于10的值替换为10。**\n",
    "\n",
    "- `a = np.random.uniform(1, 50, 20)`\n",
    "\n",
    "【知识点：数学函数、搜索】\n",
    "- 如何将大于给定值的所有值替换为给定的截止值？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **找到一个一维数字数组a中的所有峰值。峰顶是两边被较小数值包围的点。**\n",
    "\n",
    "- `a = np.array([1, 3, 7, 1, 2, 6, 0, 1])`\n",
    "\n",
    "【知识点：数学函数、搜索】\n",
    "- 如何在一维数组中找到所有的局部极大值（或峰值）？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **对于给定的一维数组，计算窗口大小为3的移动平均值。**\n",
    "\n",
    "- `z = np.random.randint(10, size=10)`\n",
    "\n",
    "【知识点：数学函数】\n",
    "- 如何计算numpy数组的移动平均值？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **对一个5x5的随机矩阵做归一化**\n",
    "\n",
    "-`Z = np.random.random((5,5))` \n",
    "\n",
    "【知识点：数学函数】\n",
    "- (提示: (x - min) / (max - min))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **用五种不同的方法去提取一个随机数组的整数部分**\n",
    "\n",
    "- `Z = np.random.uniform(0,10,10) `\n",
    "\n",
    "【知识点：数学函数】\n",
    "\n",
    "- (提示: %, np.floor, np.ceil, astype, np.trunc)"
   ]
  },
  {
   "attachments": {
    "image.png": {
     "image/png": "[encoded data, 4868 characters]"
    }
   },
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **考虑一维数组Z，构建一个二维数组，其第一行为（Z [0]，Z [1]，Z [2]），随后的每一行都移位1（最后一行应为（Z [ -3]，Z [-2]，Z [-1]）**\n",
    "\n",
    "【知识点：数学函数】\n",
    "\n",
    "- （提示np.lib.stride_tricks）\n",
    "\n",
    "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]--------> ![image.png](attachment:image.png) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **考虑两组点集P0和P1去描述一组线(二维)和一个点p,如何计算点p到每一条线 i (P0[i],P1[i])的距离？**\n",
    "- `P0 = np.random.uniform(-10,10,(10,2))\n",
    "P1 = np.random.uniform(-10,10,(10,2))\n",
    "p  = np.random.uniform(-10,10,( 1,2))`\n",
    "\n",
    "【知识点：数学函数】\n",
    "- 提示 设P(x0,y0)，直线方程为：Ax+By+C=0\n",
    "则P到直线的距离为:d=|Ax0+By0+C|/√(A²+B²)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **画正弦函数和余弦函数， x = np.arange(0, 3 * np.pi, 0.1)？**\n",
    "【知识点：数学函数】"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **减去矩阵每一行的平均值 ？**\n",
    "【知识点：数学函数】\n",
    "- 提示: mean(axis=,keepdims=)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **进行概率统计分析 ？**\n",
    "- `arr1 = np.random.randint(1,10,10)\n",
    "arr2 = np.random.randint(1,10,10))\n",
    "【知识点：数学函数】 \n",
    "平均数，中位数，方差，标准差，相关性矩阵，协方差矩阵等`\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 逻辑函数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **获取a和b元素匹配的位置。**\n",
    "- `a = np.array([1, 2, 3, 2, 3, 4, 3, 4, 5, 6])`\n",
    "- `b = np.array([7, 2, 10, 2, 7, 4, 9, 4, 9, 8])`\n",
    "\n",
    "【知识点：逻辑函数】\n",
    "- 如何得到两个数组元素匹配的位置？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **获取5到10 之间的所有元素。**\n",
    "- `a = np.array([2, 6, 1, 9, 10, 3, 27])`\n",
    "\n",
    "【知识点：逻辑函数】\n",
    "- 如何从numpy数组中提取给定范围内的所有元素？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **对于两个随机数组A和B,检查他们是否相等**\n",
    "- `A = np.random.randint(0,2,5)\n",
    "B = np.random.randint(0,2,5)`\n",
    "\n",
    "【知识点：逻辑函数】\n",
    "\n",
    "- (提示: np.allclose, np.array_equal)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **何对布尔值取反，或者原位(in-place)改变浮点数的符号(sign)？**\n",
    "\n",
    "【知识点：逻辑函数】\n",
    "- (提示: np.logical_not, np.negative)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### **找出数组中与给定值最接近的数**\n",
    "\n",
    "【知识点：逻辑函数】\n",
    "- (提示: np.abs().argmin())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.10"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
