{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(14.0,\n", " 7.6,\n", " 11.2,\n", " 12.8,\n", " 12.5,\n", " 9.9,\n", " 14.9,\n", " 9.4,\n", " 16.9,\n", " 10.2,\n", " 14.9,\n", " 18.1,\n", " 7.3,\n", " 9.8,\n", " 10.9,\n", " 12.2,\n", " 9.9,\n", " 2.9,\n", " 2.8,\n", " 15.4,\n", " 15.7,\n", " 9.7,\n", " 13.1,\n", " 13.2,\n", " 12.3,\n", " 11.7,\n", " 16.0,\n", " 12.4,\n", " 17.9,\n", " 12.2,\n", " 16.2,\n", " 18.7,\n", " 8.9,\n", " 11.9,\n", " 12.1,\n", " 14.6,\n", " 12.1,\n", " 4.7,\n", " 3.9,\n", " 16.9,\n", " 16.8,\n", " 11.3,\n", " 14.4,\n", " 15.7,\n", " 14.0,\n", " 13.6,\n", " 18.0,\n", " 13.6,\n", " 19.9,\n", " 13.7,\n", " 17.0,\n", " 20.5,\n", " 9.9,\n", " 12.5,\n", " 13.2,\n", " 16.1,\n", " 13.5,\n", " 6.3,\n", " 6.4,\n", " 17.6,\n", " 19.1,\n", " 12.8,\n", " 15.5,\n", " 16.3,\n", " 15.2,\n", " 14.6,\n", " 19.1,\n", " 14.4,\n", " 21.4,\n", " 15.1,\n", " 19.6,\n", " 21.7,\n", " 11.3,\n", " 15.0,\n", " 14.3,\n", " 16.8,\n", " 14.0,\n", " 6.8,\n", " 8.2,\n", " 19.9,\n", " 20.4,\n", " 14.6,\n", " 16.4,\n", " 18.7,\n", " 16.8,\n", " 15.8,\n", " 20.4,\n", " 15.8,\n", " 22.4,\n", " 16.2,\n", " 20.3,\n", " 23.4,\n", " 12.1,\n", " 15.5,\n", " 15.4,\n", " 18.4,\n", " 15.7,\n", " 10.2,\n", " 8.9,\n", " 21.0)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "14.0, 7.6, 11.2, 12.8, 12.5, 9.9, 14.9, 9.4, 16.9, 10.2, 14.9, 18.1, 7.3, 9.8, 10.9,12.2, 9.9, 2.9, 2.8, 15.4, 15.7, 9.7, 13.1, 13.2, 12.3, 11.7, 16.0, 12.4, 17.9, 12.2, 16.2, 18.7, 8.9, 11.9, 12.1, 14.6, 12.1, 4.7, 3.9, 16.9, 16.8, 11.3, 14.4, 15.7, 14.0, 13.6, 18.0, 13.6, 19.9, 13.7, 17.0, 20.5, 9.9, 12.5, 13.2, 16.1, 13.5, 6.3, 6.4, 17.6, 19.1, 12.8, 15.5, 16.3, 15.2, 14.6, 19.1, 14.4, 21.4, 15.1, 19.6, 21.7, 11.3, 15.0, 14.3, 16.8, 14.0, 6.8, 8.2, 19.9, 20.4, 14.6, 16.4, 18.7, 16.8, 15.8, 20.4, 15.8, 22.4, 16.2, 20.3, 23.4, 12.1, 15.5, 15.4, 18.4, 15.7, 10.2, 8.9, 21.0\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "DataS=[14.0, 7.6, 11.2, 12.8, 12.5, 9.9, 14.9, 9.4, 16.9, 10.2, 14.9, 18.1, 7.3, 9.8, 10.9,12.2, 9.9, 2.9, 2.8, 15.4, 15.7, 9.7, 13.1, 13.2, 12.3, 11.7, 16.0, 12.4, 17.9, 12.2, 16.2, 18.7, 8.9, 11.9, 12.1, 14.6, 12.1, 4.7, 3.9, 16.9, 16.8, 11.3, 14.4, 15.7, 14.0, 13.6, 18.0, 13.6, 19.9, 13.7, 17.0, 20.5, 9.9, 12.5, 13.2, 16.1, 13.5, 6.3, 6.4, 17.6, 19.1, 12.8, 15.5, 16.3, 15.2, 14.6, 19.1, 14.4, 21.4, 15.1, 19.6, 21.7, 11.3, 15.0, 14.3, 16.8, 14.0, 6.8, 8.2, 19.9, 20.4, 14.6, 16.4, 18.7, 16.8, 15.8, 20.4, 15.8, 22.4, 16.2, 20.3, 23.4, 12.1, 15.5, 15.4, 18.4, 15.7, 10.2, 8.9, 21.0\n", "]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'Data' is not defined", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mData\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;31mNameError\u001b[0m: name 'Data' is not defined" ] } ], "source": [ "Data" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[14.0,\n", " 7.6,\n", " 11.2,\n", " 12.8,\n", " 12.5,\n", " 9.9,\n", " 14.9,\n", " 9.4,\n", " 16.9,\n", " 10.2,\n", " 14.9,\n", " 18.1,\n", " 7.3,\n", " 9.8,\n", " 10.9,\n", " 12.2,\n", " 9.9,\n", " 2.9,\n", " 2.8,\n", " 15.4,\n", " 15.7,\n", " 9.7,\n", " 13.1,\n", " 13.2,\n", " 12.3,\n", " 11.7,\n", " 16.0,\n", " 12.4,\n", " 17.9,\n", " 12.2,\n", " 16.2,\n", " 18.7,\n", " 8.9,\n", " 11.9,\n", " 12.1,\n", " 14.6,\n", " 12.1,\n", " 4.7,\n", " 3.9,\n", " 16.9,\n", " 16.8,\n", " 11.3,\n", " 14.4,\n", " 15.7,\n", " 14.0,\n", " 13.6,\n", " 18.0,\n", " 13.6,\n", " 19.9,\n", " 13.7,\n", " 17.0,\n", " 20.5,\n", " 9.9,\n", " 12.5,\n", " 13.2,\n", " 16.1,\n", " 13.5,\n", " 6.3,\n", " 6.4,\n", " 17.6,\n", " 19.1,\n", " 12.8,\n", " 15.5,\n", " 16.3,\n", " 15.2,\n", " 14.6,\n", " 19.1,\n", " 14.4,\n", " 21.4,\n", " 15.1,\n", " 19.6,\n", " 21.7,\n", " 11.3,\n", " 15.0,\n", " 14.3,\n", " 16.8,\n", " 14.0,\n", " 6.8,\n", " 8.2,\n", " 19.9,\n", " 20.4,\n", " 14.6,\n", " 16.4,\n", " 18.7,\n", " 16.8,\n", " 15.8,\n", " 20.4,\n", " 15.8,\n", " 22.4,\n", " 16.2,\n", " 20.3,\n", " 23.4,\n", " 12.1,\n", " 15.5,\n", " 15.4,\n", " 18.4,\n", " 15.7,\n", " 10.2,\n", " 8.9,\n", " 21.0]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "DataS" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "14.113000000000001" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.mean(DataS)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2.8" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.min(DataS)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "23.4" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.max(DataS)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "14.5" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.median(DataS)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\u001b[1;31mSignature:\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstd\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mout\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mddof\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkeepdims\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m<\u001b[0m\u001b[0mno\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;31mDocstring:\u001b[0m\n", "Compute the standard deviation along the specified axis.\n", "\n", "Returns the standard deviation, a measure of the spread of a distribution,\n", "of the array elements. The standard deviation is computed for the\n", "flattened array by default, otherwise over the specified axis.\n", "\n", "Parameters\n", "----------\n", "a : array_like\n", " Calculate the standard deviation of these values.\n", "axis : None or int or tuple of ints, optional\n", " Axis or axes along which the standard deviation is computed. The\n", " default is to compute the standard deviation of the flattened array.\n", "\n", " .. versionadded:: 1.7.0\n", "\n", " If this is a tuple of ints, a standard deviation is performed over\n", " multiple axes, instead of a single axis or all the axes as before.\n", "dtype : dtype, optional\n", " Type to use in computing the standard deviation. For arrays of\n", " integer type the default is float64, for arrays of float types it is\n", " the same as the array type.\n", "out : ndarray, optional\n", " Alternative output array in which to place the result. It must have\n", " the same shape as the expected output but the type (of the calculated\n", " values) will be cast if necessary.\n", "ddof : int, optional\n", " Means Delta Degrees of Freedom. The divisor used in calculations\n", " is ``N - ddof``, where ``N`` represents the number of elements.\n", " By default `ddof` is zero.\n", "keepdims : bool, optional\n", " If this is set to True, the axes which are reduced are left\n", " in the result as dimensions with size one. With this option,\n", " the result will broadcast correctly against the input array.\n", "\n", " If the default value is passed, then `keepdims` will not be\n", " passed through to the `std` method of sub-classes of\n", " `ndarray`, however any non-default value will be. If the\n", " sub-class' method does not implement `keepdims` any\n", " exceptions will be raised.\n", "\n", "Returns\n", "-------\n", "standard_deviation : ndarray, see dtype parameter above.\n", " If `out` is None, return a new array containing the standard deviation,\n", " otherwise return a reference to the output array.\n", "\n", "See Also\n", "--------\n", "var, mean, nanmean, nanstd, nanvar\n", "ufuncs-output-type\n", "\n", "Notes\n", "-----\n", "The standard deviation is the square root of the average of the squared\n", "deviations from the mean, i.e., ``std = sqrt(mean(abs(x - x.mean())**2))``.\n", "\n", "The average squared deviation is normally calculated as\n", "``x.sum() / N``, where ``N = len(x)``. If, however, `ddof` is specified,\n", "the divisor ``N - ddof`` is used instead. In standard statistical\n", "practice, ``ddof=1`` provides an unbiased estimator of the variance\n", "of the infinite population. ``ddof=0`` provides a maximum likelihood\n", "estimate of the variance for normally distributed variables. The\n", "standard deviation computed in this function is the square root of\n", "the estimated variance, so even with ``ddof=1``, it will not be an\n", "unbiased estimate of the standard deviation per se.\n", "\n", "Note that, for complex numbers, `std` takes the absolute\n", "value before squaring, so that the result is always real and nonnegative.\n", "\n", "For floating-point input, the *std* is computed using the same\n", "precision the input has. Depending on the input data, this can cause\n", "the results to be inaccurate, especially for float32 (see example below).\n", "Specifying a higher-accuracy accumulator using the `dtype` keyword can\n", "alleviate this issue.\n", "\n", "Examples\n", "--------\n", ">>> a = np.array([[1, 2], [3, 4]])\n", ">>> np.std(a)\n", "1.1180339887498949 # may vary\n", ">>> np.std(a, axis=0)\n", "array([1., 1.])\n", ">>> np.std(a, axis=1)\n", "array([0.5, 0.5])\n", "\n", "In single precision, std() can be inaccurate:\n", "\n", ">>> a = np.zeros((2, 512*512), dtype=np.float32)\n", ">>> a[0, :] = 1.0\n", ">>> a[1, :] = 0.1\n", ">>> np.std(a)\n", "0.45000005\n", "\n", "Computing the standard deviation in float64 is more accurate:\n", "\n", ">>> np.std(a, dtype=np.float64)\n", "0.44999999925494177 # may vary\n", "\u001b[1;31mFile:\u001b[0m d:\\wpy64-3830\\python-3.8.3.amd64\\lib\\site-packages\\numpy\\core\\fromnumeric.py\n", "\u001b[1;31mType:\u001b[0m function\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "np.std?" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4.334094455301447" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.std(DataS,ddof=1)" ] }, { "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.8.3" } }, "nbformat": 4, "nbformat_minor": 4 }