1+ {
2+ "nbformat" : 4 ,
3+ "nbformat_minor" : 0 ,
4+ "metadata" : {
5+ "colab" : {
6+ "name" : " Measure_of_Spread.ipynb" ,
7+ "version" : " 0.3.2" ,
8+ "provenance" : []
9+ },
10+ "kernelspec" : {
11+ "name" : " python3" ,
12+ "display_name" : " Python 3"
13+ }
14+ },
15+ "cells" : [
16+ {
17+ "cell_type" : " markdown" ,
18+ "metadata" : {
19+ "id" : " wPQ-oKmUd4VC" ,
20+ "colab_type" : " text"
21+ },
22+ "source" : [
23+ " # Range : \n " ,
24+ " \n " ,
25+ " ---\n " ,
26+ " \n " ,
27+ " Range = X(lagest) - X (lowest)"
28+ ]
29+ },
30+ {
31+ "cell_type" : " code" ,
32+ "metadata" : {
33+ "id" : " zFat5FJ8d1-6" ,
34+ "colab_type" : " code" ,
35+ "colab" : {
36+ "base_uri" : " https://localhost:8080/" ,
37+ "height" : 51
38+ },
39+ "outputId" : " 10536d99-7178-4d92-8fce-3f5f325c3c14"
40+ },
41+ "source" : [
42+ " import numpy as np\n " ,
43+ " A=np.array([[10,14,11,7,9.5,15,19],[8,9,17,14.5,12,18,15.5], [15,7.5,11.5,10,10.5,7,11],[11.5,11,9,12,14,12,7.5]])\n " ,
44+ " A\n " ,
45+ " \n " ,
46+ " B=A.T\n " ,
47+ " B\n " ,
48+ " \n " ,
49+ " a=np.ptp(B, axis=0)\n " ,
50+ " b=np.ptp(B,axis=1)\n " ,
51+ " \n " ,
52+ " print(\" Range in Array A:\" ,a)\n " ,
53+ " print(\" Range in Array B:\" ,b)"
54+ ],
55+ "execution_count" : 4 ,
56+ "outputs" : [
57+ {
58+ "output_type" : " stream" ,
59+ "text" : [
60+ " Range in Array A: [12. 10. 8. 6.5]\n " ,
61+ " Range in Array B: [ 7. 6.5 8. 7.5 4.5 11. 11.5]\n "
62+ ],
63+ "name" : " stdout"
64+ }
65+ ]
66+ },
67+ {
68+ "cell_type" : " markdown" ,
69+ "metadata" : {
70+ "id" : " qmZJRD0xekaC" ,
71+ "colab_type" : " text"
72+ },
73+ "source" : [
74+ " # Quartile\n " ,
75+ " \n " ,
76+ " ---\n " ,
77+ " \n "
78+ ]
79+ },
80+ {
81+ "cell_type" : " code" ,
82+ "metadata" : {
83+ "id" : " onAG-ZzleNRO" ,
84+ "colab_type" : " code" ,
85+ "colab" : {
86+ "base_uri" : " https://localhost:8080/" ,
87+ "height" : 85
88+ },
89+ "outputId" : " 79be6256-2bf0-4d90-e955-b9f77b17d9da"
90+ },
91+ "source" : [
92+ " A=np.array([[10,14,11,7,9.5,15,19],[8,9,17,14.5,12,18,15.5], [15,7.5,11.5,10,10.5,7,11],[11.5,11,9,12,14,12,7.5]])\n " ,
93+ " \n " ,
94+ " B=A.T\n " ,
95+ " \n " ,
96+ " a=np.percentile(B,27,axis=0, interpolation='lower')\n " ,
97+ " b=np.percentile(B,25,axis=1, interpolation='lower')\n " ,
98+ " c=np.percentile(B,75,axis=0, interpolation='lower')\n " ,
99+ " d=np.percentile(B,50,axis=0, interpolation='lower')\n " ,
100+ " \n " ,
101+ " print(a)\n " ,
102+ " \n " ,
103+ " print(b)\n " ,
104+ " \n " ,
105+ " print(c)\n " ,
106+ " \n " ,
107+ " print(d)"
108+ ],
109+ "execution_count" : 5 ,
110+ "outputs" : [
111+ {
112+ "output_type" : " stream" ,
113+ "text" : [
114+ " [9.5 9. 7.5 9. ]\n " ,
115+ " [8. 7.5 9. 7. 9.5 7. 7.5]\n " ,
116+ " [14. 15.5 11. 12. ]\n " ,
117+ " [11. 14.5 10.5 11.5]\n "
118+ ],
119+ "name" : " stdout"
120+ }
121+ ]
122+ },
123+ {
124+ "cell_type" : " markdown" ,
125+ "metadata" : {
126+ "id" : " 7Do6eEXLgj2i" ,
127+ "colab_type" : " text"
128+ },
129+ "source" : [
130+ " # inter-qurtile range\n " ,
131+ " \n " ,
132+ " ---\n " ,
133+ " \n " ,
134+ " \n "
135+ ]
136+ },
137+ {
138+ "cell_type" : " code" ,
139+ "metadata" : {
140+ "id" : " v0J_1_TVgqF_" ,
141+ "colab_type" : " code" ,
142+ "colab" : {
143+ "base_uri" : " https://localhost:8080/" ,
144+ "height" : 34
145+ },
146+ "outputId" : " 0956b1cd-d0f9-4058-ccd3-d50a41a4caed"
147+ },
148+ "source" : [
149+ " import numpy as np\n " ,
150+ " from scipy.stats import iqr\n " ,
151+ " A=np.array([[10,14,11,7,9.5,15,19],[8,9,17,14.5,12,18,15.5], [15,7.5,11.5,10,10.5,7,11],[11.5,11,9,12,14,12,7.5]])\n " ,
152+ " \n " ,
153+ " B=A.T\n " ,
154+ " \n " ,
155+ " a=iqr(B, axis=0 , rng=(25, 75), interpolation='lower')\n " ,
156+ " b=iqr(B, axis=1 , rng=(25, 75), interpolation='lower')\n " ,
157+ " \n " ,
158+ " print(a,b)"
159+ ],
160+ "execution_count" : 7 ,
161+ "outputs" : [
162+ {
163+ "output_type" : " stream" ,
164+ "text" : [
165+ " [4.5 6.5 3.5 3. ] [3.5 3.5 2.5 5. 2.5 8. 8. ]\n "
166+ ],
167+ "name" : " stdout"
168+ }
169+ ]
170+ },
171+ {
172+ "cell_type" : " markdown" ,
173+ "metadata" : {
174+ "id" : " TeDGcMkvg5je" ,
175+ "colab_type" : " text"
176+ },
177+ "source" : [
178+ " # Variance\n " ,
179+ " \n " ,
180+ " ---\n " ,
181+ " \n "
182+ ]
183+ },
184+ {
185+ "cell_type" : " code" ,
186+ "metadata" : {
187+ "id" : " RA52W0_HgrOz" ,
188+ "colab_type" : " code" ,
189+ "colab" : {
190+ "base_uri" : " https://localhost:8080/" ,
191+ "height" : 51
192+ },
193+ "outputId" : " 4554289c-45b5-4a5c-d611-4092f80e7ee8"
194+ },
195+ "source" : [
196+ " import numpy as np\n " ,
197+ " A=np.array([[10,14,11,7,9.5,15,19],[8,9,17,14.5,12,18,15.5],\n " ,
198+ " [15,7.5,11.5,10,10.5,7,11],[11.5,11,9,12,14,12,7.5]])\n " ,
199+ " \n " ,
200+ " B=A.T\n " ,
201+ " \n " ,
202+ " a = np.var(B,axis=0)\n " ,
203+ " b = np.var(B,axis=1)\n " ,
204+ " \n " ,
205+ " print(a)\n " ,
206+ " \n " ,
207+ " print(b)"
208+ ],
209+ "execution_count" : 8 ,
210+ "outputs" : [
211+ {
212+ "output_type" : " stream" ,
213+ "text" : [
214+ " [13.98979592 12.8877551 6.12244898 3.92857143]\n " ,
215+ " [ 6.546875 5.921875 8.796875 7.546875 2.875 16.5 19.0625 ]\n "
216+ ],
217+ "name" : " stdout"
218+ }
219+ ]
220+ },
221+ {
222+ "cell_type" : " markdown" ,
223+ "metadata" : {
224+ "id" : " H40m2neihCJC" ,
225+ "colab_type" : " text"
226+ },
227+ "source" : [
228+ " # Standard deviation\n " ,
229+ " \n " ,
230+ " ---\n " ,
231+ " \n "
232+ ]
233+ },
234+ {
235+ "cell_type" : " code" ,
236+ "metadata" : {
237+ "id" : " 9pETuLnmhAsc" ,
238+ "colab_type" : " code" ,
239+ "colab" : {
240+ "base_uri" : " https://localhost:8080/" ,
241+ "height" : 68
242+ },
243+ "outputId" : " 1ff2c7d4-2723-4a54-cf94-5e5968bfcd17"
244+ },
245+ "source" : [
246+ " import numpy as np\n " ,
247+ " A=np.array([[10,14,11,7,9.5,15,19],[8,9,17,14.5,12,18,15.5],\n " ,
248+ " [15,7.5,11.5,10,10.5,7,11],[11.5,11,9,12,14,12,7.5]])\n " ,
249+ " B=A.T\n " ,
250+ " a = np.std(B,axis=0)\n " ,
251+ " b = np.std(B,axis=1)\n " ,
252+ " print(a)\n " ,
253+ " \n " ,
254+ " print(b)"
255+ ],
256+ "execution_count" : 9 ,
257+ "outputs" : [
258+ {
259+ "output_type" : " stream" ,
260+ "text" : [
261+ " [3.74029356 3.58995196 2.4743583 1.98206242]\n " ,
262+ " [2.55868619 2.43349029 2.96595263 2.74715762 1.6955825 4.0620192\n " ,
263+ " 4.3660623 ]\n "
264+ ],
265+ "name" : " stdout"
266+ }
267+ ]
268+ }
269+ ]
270+ }
0 commit comments