├── GWU_Logo_Horizontal.png ├── data.csv ├── Project.toml ├── heart.csv └── Lesson0Julia.ipynb /GWU_Logo_Horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanklopper/BiostatisticalApplicationsForPublicHealth/main/GWU_Logo_Horizontal.png -------------------------------------------------------------------------------- /data.csv: -------------------------------------------------------------------------------- 1 | Age,DBP,Diet,LDL 2 | 50,88,0,78.0 3 | 50,88,0,87.0 4 | 50,89,0,91.75 5 | 52,89,0,91.75 6 | 52,89,0,90.75 7 | 52,89,0,80.75 8 | 53,89,0,76.25 9 | 53,89,0,91.25 10 | 53,89,0,77.25 11 | 53,90,0,94.0 12 | 53,90,0,88.0 13 | 53,90,0,91.0 14 | 54,91,0,81.25 15 | 55,91,0,83.75 16 | 55,91,0,86.75 17 | 55,91,0,94.75 18 | 56,92,0,80.0 19 | 56,92,0,83.0 20 | 57,92,0,86.5 21 | 57,92,0,81.5 22 | 57,92,0,84.5 23 | 58,93,0,83.75 24 | 59,93,0,99.25 25 | 59,93,0,89.25 26 | 59,94,0,88.0 27 | 60,94,0,95.5 28 | 60,94,0,87.5 29 | 60,94,0,89.5 30 | 60,95,0,82.25 31 | 60,95,0,89.25 32 | 60,95,0,88.25 33 | 60,95,0,91.25 34 | 60,96,0,98.0 35 | 61,97,0,96.25 36 | 61,97,0,101.25 37 | 62,97,0,87.75 38 | 62,98,0,86.5 39 | 63,98,0,89.0 40 | 63,98,0,88.0 41 | 63,98,0,105.0 42 | 64,98,0,90.5 43 | 64,98,0,94.5 44 | 64,99,0,94.25 45 | 64,99,0,98.25 46 | 64,99,0,102.25 47 | 64,99,0,104.25 48 | 64,99,0,93.25 49 | 65,99,0,100.75 50 | 65,99,0,93.75 51 | 65,100,0,95.5 52 | 65,100,0,102.5 53 | 66,100,0,98.0 54 | 66,100,1,106.5 55 | 66,101,1,96.25 56 | 66,101,1,93.25 57 | 66,102,1,104.0 58 | 66,102,1,100.0 59 | 67,102,1,110.5 60 | 67,102,1,94.5 61 | 68,102,1,91.0 62 | 68,102,1,95.0 63 | 68,103,1,93.75 64 | 69,103,1,109.25 65 | 69,103,1,95.25 66 | 69,104,1,98.0 67 | 69,104,1,98.0 68 | 69,104,1,94.0 69 | 70,104,1,103.5 70 | 70,104,1,104.5 71 | 70,104,1,102.5 72 | 71,104,1,108.0 73 | 71,105,1,94.75 74 | 71,105,1,108.75 75 | 71,105,1,112.75 76 | 71,105,1,112.75 77 | 72,105,1,103.25 78 | 72,105,1,112.25 79 | 72,105,1,102.25 80 | 73,106,1,104.5 81 | 73,106,1,106.5 82 | 73,106,1,102.5 83 | 73,106,1,104.5 84 | 74,107,1,107.75 85 | 74,107,1,110.75 86 | 75,107,1,111.25 87 | 75,108,1,119.0 88 | 75,108,1,100.0 89 | 75,108,1,110.0 90 | 76,108,1,114.5 91 | 77,108,1,119.0 92 | 77,108,1,103.0 93 | 77,108,1,100.0 94 | 77,108,1,108.0 95 | 77,108,1,113.0 96 | 77,108,1,102.0 97 | 77,109,1,109.75 98 | 78,109,1,106.25 99 | 78,109,1,101.25 100 | 78,109,1,105.25 101 | 78,110,1,113.0 102 | -------------------------------------------------------------------------------- /Project.toml: -------------------------------------------------------------------------------- 1 | name = "Biostatistics" 2 | uuid = "2dd4b753-a8e1-4d05-9e74-f67f303d7708" 3 | authors = ["juanklopper "] 4 | version = "0.1.0" 5 | 6 | [deps] 7 | CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" 8 | CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" 9 | CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" 10 | Chain = "8be319e6-bccf-4806-a6f7-6fae938471bc" 11 | Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5" 12 | DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" 13 | DataFramesMeta = "1313f7d8-7da2-5740-9ea0-a2ca25f37964" 14 | Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" 15 | Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" 16 | Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" 17 | FreqTables = "da1fdf0e-e0ff-5433-a45f-9bb5ff651cb1" 18 | GLM = "38e38edf-8417-5370-95a0-9cbb8c7f171a" 19 | GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" 20 | Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" 21 | HypothesisTests = "09f84164-cd44-5f33-b23f-e6b0d136a0d5" 22 | IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 23 | KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b" 24 | LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" 25 | Lux = "b2108857-7c20-44ae-9111-449ecde12c47" 26 | MLBase = "f0e99cf1-93fa-52ec-9ecc-5026115318e0" 27 | MultivariateStats = "6f286f6a-111f-5878-ab1e-185364afe411" 28 | NMF = "6ef6ca0d-6ad7-5ff6-b225-e928bfa0a386" 29 | Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2" 30 | PlotThemes = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a" 31 | Plotly = "58dd65bb-95f3-509e-9936-c39a10fdeae7" 32 | PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5" 33 | PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" 34 | PlotlyKaleido = "f2990250-8cf9-495f-b13a-cce12b45703c" 35 | Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" 36 | Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781" 37 | Query = "1a8c2f83-1ff3-5112-b086-8aa67b057ba1" 38 | RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b" 39 | StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" 40 | StatsKit = "2cb19f9e-ec4d-5c53-8573-a4542a68d3f0" 41 | StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d" 42 | StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd" 43 | TidierPlots = "337ecbd1-5042-4e2a-ae6f-ca776f97570a" 44 | TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e" 45 | WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008" 46 | WebIO = "0f1e0344-ec1d-5b48-a673-e5cf874b6c29" 47 | Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" 48 | 49 | [compat] 50 | CairoMakie = "0.10.0" 51 | Chain = "0.6.0" 52 | DataFramesMeta = "0.15.3" 53 | Downloads = "1.6.0" 54 | FreqTables = "0.4.6" 55 | LaTeXStrings = "1.3.1" 56 | PlotThemes = "3.2.0" 57 | Query = "1.0.0" 58 | TidierPlots = "0.5.2" 59 | -------------------------------------------------------------------------------- /heart.csv: -------------------------------------------------------------------------------- 1 | Age,Sex,ChestPainType,RestingBP,Cholesterol,FastingBS,RestingECG,MaxHR,ExerciseAngina,Oldpeak,ST_Slope,HeartDisease 2 | 40,M,ATA,140,289,0,Normal,172,N,0,Up,0 3 | 49,F,NAP,160,180,0,Normal,156,N,1,Flat,1 4 | 37,M,ATA,130,283,0,ST,98,N,0,Up,0 5 | 48,F,ASY,138,214,0,Normal,108,Y,1.5,Flat,1 6 | 54,M,NAP,150,195,0,Normal,122,N,0,Up,0 7 | 39,M,NAP,120,339,0,Normal,170,N,0,Up,0 8 | 45,F,ATA,130,237,0,Normal,170,N,0,Up,0 9 | 54,M,ATA,110,208,0,Normal,142,N,0,Up,0 10 | 37,M,ASY,140,207,0,Normal,130,Y,1.5,Flat,1 11 | 48,F,ATA,120,284,0,Normal,120,N,0,Up,0 12 | 37,F,NAP,130,211,0,Normal,142,N,0,Up,0 13 | 58,M,ATA,136,164,0,ST,99,Y,2,Flat,1 14 | 39,M,ATA,120,204,0,Normal,145,N,0,Up,0 15 | 49,M,ASY,140,234,0,Normal,140,Y,1,Flat,1 16 | 42,F,NAP,115,211,0,ST,137,N,0,Up,0 17 | 54,F,ATA,120,273,0,Normal,150,N,1.5,Flat,0 18 | 38,M,ASY,110,196,0,Normal,166,N,0,Flat,1 19 | 43,F,ATA,120,201,0,Normal,165,N,0,Up,0 20 | 60,M,ASY,100,248,0,Normal,125,N,1,Flat,1 21 | 36,M,ATA,120,267,0,Normal,160,N,3,Flat,1 22 | 43,F,TA,100,223,0,Normal,142,N,0,Up,0 23 | 44,M,ATA,120,184,0,Normal,142,N,1,Flat,0 24 | 49,F,ATA,124,201,0,Normal,164,N,0,Up,0 25 | 44,M,ATA,150,288,0,Normal,150,Y,3,Flat,1 26 | 40,M,NAP,130,215,0,Normal,138,N,0,Up,0 27 | 36,M,NAP,130,209,0,Normal,178,N,0,Up,0 28 | 53,M,ASY,124,260,0,ST,112,Y,3,Flat,0 29 | 52,M,ATA,120,284,0,Normal,118,N,0,Up,0 30 | 53,F,ATA,113,468,0,Normal,127,N,0,Up,0 31 | 51,M,ATA,125,188,0,Normal,145,N,0,Up,0 32 | 53,M,NAP,145,518,0,Normal,130,N,0,Flat,1 33 | 56,M,NAP,130,167,0,Normal,114,N,0,Up,0 34 | 54,M,ASY,125,224,0,Normal,122,N,2,Flat,1 35 | 41,M,ASY,130,172,0,ST,130,N,2,Flat,1 36 | 43,F,ATA,150,186,0,Normal,154,N,0,Up,0 37 | 32,M,ATA,125,254,0,Normal,155,N,0,Up,0 38 | 65,M,ASY,140,306,1,Normal,87,Y,1.5,Flat,1 39 | 41,F,ATA,110,250,0,ST,142,N,0,Up,0 40 | 48,F,ATA,120,177,1,ST,148,N,0,Up,0 41 | 48,F,ASY,150,227,0,Normal,130,Y,1,Flat,0 42 | 54,F,ATA,150,230,0,Normal,130,N,0,Up,0 43 | 54,F,NAP,130,294,0,ST,100,Y,0,Flat,1 44 | 35,M,ATA,150,264,0,Normal,168,N,0,Up,0 45 | 52,M,NAP,140,259,0,ST,170,N,0,Up,0 46 | 43,M,ASY,120,175,0,Normal,120,Y,1,Flat,1 47 | 59,M,NAP,130,318,0,Normal,120,Y,1,Flat,0 48 | 37,M,ASY,120,223,0,Normal,168,N,0,Up,0 49 | 50,M,ATA,140,216,0,Normal,170,N,0,Up,0 50 | 36,M,NAP,112,340,0,Normal,184,N,1,Flat,0 51 | 41,M,ASY,110,289,0,Normal,170,N,0,Flat,1 52 | 50,M,ASY,130,233,0,Normal,121,Y,2,Flat,1 53 | 47,F,ASY,120,205,0,Normal,98,Y,2,Flat,1 54 | 45,M,ATA,140,224,1,Normal,122,N,0,Up,0 55 | 41,F,ATA,130,245,0,Normal,150,N,0,Up,0 56 | 52,F,ASY,130,180,0,Normal,140,Y,1.5,Flat,0 57 | 51,F,ATA,160,194,0,Normal,170,N,0,Up,0 58 | 31,M,ASY,120,270,0,Normal,153,Y,1.5,Flat,1 59 | 58,M,NAP,130,213,0,ST,140,N,0,Flat,1 60 | 54,M,ASY,150,365,0,ST,134,N,1,Up,0 61 | 52,M,ASY,112,342,0,ST,96,Y,1,Flat,1 62 | 49,M,ATA,100,253,0,Normal,174,N,0,Up,0 63 | 43,F,NAP,150,254,0,Normal,175,N,0,Up,0 64 | 45,M,ASY,140,224,0,Normal,144,N,0,Up,0 65 | 46,M,ASY,120,277,0,Normal,125,Y,1,Flat,1 66 | 50,F,ATA,110,202,0,Normal,145,N,0,Up,0 67 | 37,F,ATA,120,260,0,Normal,130,N,0,Up,0 68 | 45,F,ASY,132,297,0,Normal,144,N,0,Up,0 69 | 32,M,ATA,110,225,0,Normal,184,N,0,Up,0 70 | 52,M,ASY,160,246,0,ST,82,Y,4,Flat,1 71 | 44,M,ASY,150,412,0,Normal,170,N,0,Up,0 72 | 57,M,ATA,140,265,0,ST,145,Y,1,Flat,1 73 | 44,M,ATA,130,215,0,Normal,135,N,0,Up,0 74 | 52,M,ASY,120,182,0,Normal,150,N,0,Flat,1 75 | 44,F,ASY,120,218,0,ST,115,N,0,Up,0 76 | 55,M,ASY,140,268,0,Normal,128,Y,1.5,Flat,1 77 | 46,M,NAP,150,163,0,Normal,116,N,0,Up,0 78 | 32,M,ASY,118,529,0,Normal,130,N,0,Flat,1 79 | 35,F,ASY,140,167,0,Normal,150,N,0,Up,0 80 | 52,M,ATA,140,100,0,Normal,138,Y,0,Up,0 81 | 49,M,ASY,130,206,0,Normal,170,N,0,Flat,1 82 | 55,M,NAP,110,277,0,Normal,160,N,0,Up,0 83 | 54,M,ATA,120,238,0,Normal,154,N,0,Up,0 84 | 63,M,ASY,150,223,0,Normal,115,N,0,Flat,1 85 | 52,M,ATA,160,196,0,Normal,165,N,0,Up,0 86 | 56,M,ASY,150,213,1,Normal,125,Y,1,Flat,1 87 | 66,M,ASY,140,139,0,Normal,94,Y,1,Flat,1 88 | 65,M,ASY,170,263,1,Normal,112,Y,2,Flat,1 89 | 53,F,ATA,140,216,0,Normal,142,Y,2,Flat,0 90 | 43,M,TA,120,291,0,ST,155,N,0,Flat,1 91 | 55,M,ASY,140,229,0,Normal,110,Y,0.5,Flat,0 92 | 49,F,ATA,110,208,0,Normal,160,N,0,Up,0 93 | 39,M,ASY,130,307,0,Normal,140,N,0,Up,0 94 | 52,F,ATA,120,210,0,Normal,148,N,0,Up,0 95 | 48,M,ASY,160,329,0,Normal,92,Y,1.5,Flat,1 96 | 39,F,NAP,110,182,0,ST,180,N,0,Up,0 97 | 58,M,ASY,130,263,0,Normal,140,Y,2,Flat,1 98 | 43,M,ATA,142,207,0,Normal,138,N,0,Up,0 99 | 39,M,NAP,160,147,1,Normal,160,N,0,Up,0 100 | 56,M,ASY,120,85,0,Normal,140,N,0,Up,0 101 | 41,M,ATA,125,269,0,Normal,144,N,0,Up,0 102 | 65,M,ASY,130,275,0,ST,115,Y,1,Flat,1 103 | 51,M,ASY,130,179,0,Normal,100,N,0,Up,0 104 | 40,F,ASY,150,392,0,Normal,130,N,2,Flat,1 105 | 40,M,ASY,120,466,1,Normal,152,Y,1,Flat,1 106 | 46,M,ASY,118,186,0,Normal,124,N,0,Flat,1 107 | 57,M,ATA,140,260,1,Normal,140,N,0,Up,0 108 | 48,F,ASY,120,254,0,ST,110,N,0,Up,0 109 | 34,M,ATA,150,214,0,ST,168,N,0,Up,0 110 | 50,M,ASY,140,129,0,Normal,135,N,0,Up,0 111 | 39,M,ATA,190,241,0,Normal,106,N,0,Up,0 112 | 59,F,ATA,130,188,0,Normal,124,N,1,Flat,0 113 | 57,M,ASY,150,255,0,Normal,92,Y,3,Flat,1 114 | 47,M,ASY,140,276,1,Normal,125,Y,0,Up,0 115 | 38,M,ATA,140,297,0,Normal,150,N,0,Up,0 116 | 49,F,NAP,130,207,0,ST,135,N,0,Up,0 117 | 33,F,ASY,100,246,0,Normal,150,Y,1,Flat,1 118 | 38,M,ASY,120,282,0,Normal,170,N,0,Flat,1 119 | 59,F,ASY,130,338,1,ST,130,Y,1.5,Flat,1 120 | 35,F,TA,120,160,0,ST,185,N,0,Up,0 121 | 34,M,TA,140,156,0,Normal,180,N,0,Flat,1 122 | 47,F,NAP,135,248,1,Normal,170,N,0,Flat,1 123 | 52,F,NAP,125,272,0,Normal,139,N,0,Up,0 124 | 46,M,ASY,110,240,0,ST,140,N,0,Up,0 125 | 58,F,ATA,180,393,0,Normal,110,Y,1,Flat,1 126 | 58,M,ATA,130,230,0,Normal,150,N,0,Up,0 127 | 54,M,ATA,120,246,0,Normal,110,N,0,Up,0 128 | 34,F,ATA,130,161,0,Normal,190,N,0,Up,0 129 | 48,F,ASY,108,163,0,Normal,175,N,2,Up,0 130 | 54,F,ATA,120,230,1,Normal,140,N,0,Up,0 131 | 42,M,NAP,120,228,0,Normal,152,Y,1.5,Flat,0 132 | 38,M,NAP,145,292,0,Normal,130,N,0,Up,0 133 | 46,M,ASY,110,202,0,Normal,150,Y,0,Flat,1 134 | 56,M,ASY,170,388,0,ST,122,Y,2,Flat,1 135 | 56,M,ASY,150,230,0,ST,124,Y,1.5,Flat,1 136 | 61,F,ASY,130,294,0,ST,120,Y,1,Flat,0 137 | 49,M,NAP,115,265,0,Normal,175,N,0,Flat,1 138 | 43,F,ATA,120,215,0,ST,175,N,0,Up,0 139 | 39,M,ATA,120,241,0,ST,146,N,2,Up,0 140 | 54,M,ASY,140,166,0,Normal,118,Y,0,Flat,1 141 | 43,M,ASY,150,247,0,Normal,130,Y,2,Flat,1 142 | 52,M,ASY,160,331,0,Normal,94,Y,2.5,Flat,1 143 | 50,M,ASY,140,341,0,ST,125,Y,2.5,Flat,1 144 | 47,M,ASY,160,291,0,ST,158,Y,3,Flat,1 145 | 53,M,ASY,140,243,0,Normal,155,N,0,Up,0 146 | 56,F,ATA,120,279,0,Normal,150,N,1,Flat,1 147 | 39,M,ASY,110,273,0,Normal,132,N,0,Up,0 148 | 42,M,ATA,120,198,0,Normal,155,N,0,Up,0 149 | 43,F,ATA,120,249,0,ST,176,N,0,Up,0 150 | 50,M,ATA,120,168,0,Normal,160,N,0,Up,0 151 | 54,M,ASY,130,603,1,Normal,125,Y,1,Flat,1 152 | 39,M,ATA,130,215,0,Normal,120,N,0,Up,0 153 | 48,M,ATA,100,159,0,Normal,100,N,0,Up,0 154 | 40,M,ATA,130,275,0,Normal,150,N,0,Up,0 155 | 55,M,ASY,120,270,0,Normal,140,N,0,Up,0 156 | 41,M,ATA,120,291,0,ST,160,N,0,Up,0 157 | 56,M,ASY,155,342,1,Normal,150,Y,3,Flat,1 158 | 38,M,ASY,110,190,0,Normal,150,Y,1,Flat,1 159 | 49,M,ASY,140,185,0,Normal,130,N,0,Up,0 160 | 44,M,ASY,130,290,0,Normal,100,Y,2,Flat,1 161 | 54,M,ATA,160,195,0,ST,130,N,1,Up,0 162 | 59,M,ASY,140,264,1,LVH,119,Y,0,Flat,1 163 | 49,M,ASY,128,212,0,Normal,96,Y,0,Flat,1 164 | 47,M,ATA,160,263,0,Normal,174,N,0,Up,0 165 | 42,M,ATA,120,196,0,Normal,150,N,0,Up,0 166 | 52,F,ATA,140,225,0,Normal,140,N,0,Up,0 167 | 46,M,TA,140,272,1,Normal,175,N,2,Flat,1 168 | 50,M,ASY,140,231,0,ST,140,Y,5,Flat,1 169 | 48,M,ATA,140,238,0,Normal,118,N,0,Up,0 170 | 58,M,ASY,135,222,0,Normal,100,N,0,Up,0 171 | 58,M,NAP,140,179,0,Normal,160,N,0,Up,0 172 | 29,M,ATA,120,243,0,Normal,160,N,0,Up,0 173 | 40,M,NAP,140,235,0,Normal,188,N,0,Up,0 174 | 53,M,ATA,140,320,0,Normal,162,N,0,Up,0 175 | 49,M,NAP,140,187,0,Normal,172,N,0,Up,0 176 | 52,M,ASY,140,266,0,Normal,134,Y,2,Flat,1 177 | 43,M,ASY,140,288,0,Normal,135,Y,2,Flat,1 178 | 54,M,ASY,140,216,0,Normal,105,N,1.5,Flat,1 179 | 59,M,ATA,140,287,0,Normal,150,N,0,Up,0 180 | 37,M,NAP,130,194,0,Normal,150,N,0,Up,0 181 | 46,F,ASY,130,238,0,Normal,90,N,0,Up,0 182 | 52,M,ASY,130,225,0,Normal,120,Y,2,Flat,1 183 | 51,M,ATA,130,224,0,Normal,150,N,0,Up,0 184 | 52,M,ASY,140,404,0,Normal,124,Y,2,Flat,1 185 | 46,M,ASY,110,238,0,ST,140,Y,1,Flat,0 186 | 54,F,ATA,160,312,0,Normal,130,N,0,Up,0 187 | 58,M,NAP,160,211,1,ST,92,N,0,Flat,1 188 | 58,M,ATA,130,251,0,Normal,110,N,0,Up,0 189 | 41,M,ASY,120,237,1,Normal,138,Y,1,Flat,1 190 | 50,F,ASY,120,328,0,Normal,110,Y,1,Flat,0 191 | 53,M,ASY,180,285,0,ST,120,Y,1.5,Flat,1 192 | 46,M,ASY,180,280,0,ST,120,N,0,Up,0 193 | 50,M,ATA,170,209,0,ST,116,N,0,Up,0 194 | 48,M,ATA,130,245,0,Normal,160,N,0,Up,0 195 | 45,M,NAP,135,192,0,Normal,110,N,0,Up,0 196 | 41,F,ATA,125,184,0,Normal,180,N,0,Up,0 197 | 62,F,TA,160,193,0,Normal,116,N,0,Up,0 198 | 49,M,ASY,120,297,0,Normal,132,N,1,Flat,0 199 | 42,M,ATA,150,268,0,Normal,136,N,0,Up,0 200 | 53,M,ASY,120,246,0,Normal,116,Y,0,Flat,1 201 | 57,F,TA,130,308,0,Normal,98,N,1,Flat,0 202 | 47,M,TA,110,249,0,Normal,150,N,0,Up,0 203 | 46,M,NAP,120,230,0,Normal,150,N,0,Up,0 204 | 42,M,NAP,160,147,0,Normal,146,N,0,Up,0 205 | 31,F,ATA,100,219,0,ST,150,N,0,Up,0 206 | 56,M,ATA,130,184,0,Normal,100,N,0,Up,0 207 | 50,M,ASY,150,215,0,Normal,140,Y,0,Up,0 208 | 35,M,ATA,120,308,0,LVH,180,N,0,Up,0 209 | 35,M,ATA,110,257,0,Normal,140,N,0,Flat,1 210 | 28,M,ATA,130,132,0,LVH,185,N,0,Up,0 211 | 54,M,ASY,125,216,0,Normal,140,N,0,Flat,1 212 | 48,M,ASY,106,263,1,Normal,110,N,0,Flat,1 213 | 50,F,NAP,140,288,0,Normal,140,Y,0,Flat,1 214 | 56,M,NAP,130,276,0,Normal,128,Y,1,Up,0 215 | 56,F,NAP,130,219,0,ST,164,N,0,Up,0 216 | 47,M,ASY,150,226,0,Normal,98,Y,1.5,Flat,1 217 | 30,F,TA,170,237,0,ST,170,N,0,Up,0 218 | 39,M,ASY,110,280,0,Normal,150,N,0,Flat,1 219 | 54,M,NAP,120,217,0,Normal,137,N,0,Up,0 220 | 55,M,ATA,140,196,0,Normal,150,N,0,Up,0 221 | 29,M,ATA,140,263,0,Normal,170,N,0,Up,0 222 | 46,M,ASY,130,222,0,Normal,112,N,0,Flat,1 223 | 51,F,ASY,160,303,0,Normal,150,Y,1,Flat,1 224 | 48,F,NAP,120,195,0,Normal,125,N,0,Up,0 225 | 33,M,NAP,120,298,0,Normal,185,N,0,Up,0 226 | 55,M,ATA,120,256,1,Normal,137,N,0,Up,0 227 | 50,M,ASY,145,264,0,Normal,150,N,0,Flat,1 228 | 53,M,NAP,120,195,0,Normal,140,N,0,Up,0 229 | 38,M,ASY,92,117,0,Normal,134,Y,2.5,Flat,1 230 | 41,M,ATA,120,295,0,Normal,170,N,0,Up,0 231 | 37,F,ASY,130,173,0,ST,184,N,0,Up,0 232 | 37,M,ASY,130,315,0,Normal,158,N,0,Up,0 233 | 40,M,NAP,130,281,0,Normal,167,N,0,Up,0 234 | 38,F,ATA,120,275,0,Normal,129,N,0,Up,0 235 | 41,M,ASY,112,250,0,Normal,142,N,0,Up,0 236 | 54,F,ATA,140,309,0,ST,140,N,0,Up,0 237 | 39,M,ATA,120,200,0,Normal,160,Y,1,Flat,0 238 | 41,M,ASY,120,336,0,Normal,118,Y,3,Flat,1 239 | 55,M,TA,140,295,0,Normal,136,N,0,Flat,1 240 | 48,M,ASY,160,355,0,Normal,99,Y,2,Flat,1 241 | 48,M,ASY,160,193,0,Normal,102,Y,3,Flat,1 242 | 55,M,ATA,145,326,0,Normal,155,N,0,Up,0 243 | 54,M,ASY,200,198,0,Normal,142,Y,2,Flat,1 244 | 55,M,ATA,160,292,1,Normal,143,Y,2,Flat,1 245 | 43,F,ATA,120,266,0,Normal,118,N,0,Up,0 246 | 48,M,ASY,160,268,0,Normal,103,Y,1,Flat,1 247 | 54,M,TA,120,171,0,Normal,137,N,2,Up,0 248 | 54,M,NAP,120,237,0,Normal,150,Y,1.5,Flat,1 249 | 48,M,ASY,122,275,1,ST,150,Y,2,Down,1 250 | 45,M,ASY,130,219,0,ST,130,Y,1,Flat,1 251 | 49,M,ASY,130,341,0,Normal,120,Y,1,Flat,1 252 | 44,M,ASY,135,491,0,Normal,135,N,0,Flat,1 253 | 48,M,ASY,120,260,0,Normal,115,N,2,Flat,1 254 | 61,M,ASY,125,292,0,ST,115,Y,0,Up,0 255 | 62,M,ATA,140,271,0,Normal,152,N,1,Up,0 256 | 55,M,ASY,145,248,0,Normal,96,Y,2,Flat,1 257 | 53,F,NAP,120,274,0,Normal,130,N,0,Up,0 258 | 55,F,ATA,130,394,0,LVH,150,N,0,Up,0 259 | 36,M,NAP,150,160,0,Normal,172,N,0,Up,0 260 | 51,F,NAP,150,200,0,Normal,120,N,0.5,Up,0 261 | 55,F,ATA,122,320,0,Normal,155,N,0,Up,0 262 | 46,M,ATA,140,275,0,Normal,165,Y,0,Up,0 263 | 54,F,ATA,120,221,0,Normal,138,N,1,Up,0 264 | 46,M,ASY,120,231,0,Normal,115,Y,0,Flat,1 265 | 59,M,ASY,130,126,0,Normal,125,N,0,Flat,1 266 | 47,M,NAP,140,193,0,Normal,145,Y,1,Flat,1 267 | 54,M,ATA,160,305,0,Normal,175,N,0,Up,0 268 | 52,M,ASY,130,298,0,Normal,110,Y,1,Flat,1 269 | 34,M,ATA,98,220,0,Normal,150,N,0,Up,0 270 | 54,M,ASY,130,242,0,Normal,91,Y,1,Flat,1 271 | 47,F,NAP,130,235,0,Normal,145,N,2,Flat,0 272 | 45,M,ASY,120,225,0,Normal,140,N,0,Up,0 273 | 32,F,ATA,105,198,0,Normal,165,N,0,Up,0 274 | 55,M,ASY,140,201,0,Normal,130,Y,3,Flat,1 275 | 55,M,NAP,120,220,0,LVH,134,N,0,Up,0 276 | 45,F,ATA,180,295,0,Normal,180,N,0,Up,0 277 | 59,M,NAP,180,213,0,Normal,100,N,0,Up,0 278 | 51,M,NAP,135,160,0,Normal,150,N,2,Flat,1 279 | 52,M,ASY,170,223,0,Normal,126,Y,1.5,Flat,1 280 | 57,F,ASY,180,347,0,ST,126,Y,0.8,Flat,0 281 | 54,F,ATA,130,253,0,ST,155,N,0,Up,0 282 | 60,M,NAP,120,246,0,LVH,135,N,0,Up,0 283 | 49,M,ASY,150,222,0,Normal,122,N,2,Flat,1 284 | 51,F,NAP,130,220,0,Normal,160,Y,2,Up,0 285 | 55,F,ATA,110,344,0,ST,160,N,0,Up,0 286 | 42,M,ASY,140,358,0,Normal,170,N,0,Up,0 287 | 51,F,NAP,110,190,0,Normal,120,N,0,Up,0 288 | 59,M,ASY,140,169,0,Normal,140,N,0,Up,0 289 | 53,M,ATA,120,181,0,Normal,132,N,0,Up,0 290 | 48,F,ATA,133,308,0,ST,156,N,2,Up,0 291 | 36,M,ATA,120,166,0,Normal,180,N,0,Up,0 292 | 48,M,NAP,110,211,0,Normal,138,N,0,Up,0 293 | 47,F,ATA,140,257,0,Normal,135,N,1,Up,0 294 | 53,M,ASY,130,182,0,Normal,148,N,0,Up,0 295 | 65,M,ASY,115,0,0,Normal,93,Y,0,Flat,1 296 | 32,M,TA,95,0,1,Normal,127,N,0.7,Up,1 297 | 61,M,ASY,105,0,1,Normal,110,Y,1.5,Up,1 298 | 50,M,ASY,145,0,1,Normal,139,Y,0.7,Flat,1 299 | 57,M,ASY,110,0,1,ST,131,Y,1.4,Up,1 300 | 51,M,ASY,110,0,1,Normal,92,N,0,Flat,1 301 | 47,M,ASY,110,0,1,ST,149,N,2.1,Up,1 302 | 60,M,ASY,160,0,1,Normal,149,N,0.4,Flat,1 303 | 55,M,ATA,140,0,0,ST,150,N,0.2,Up,0 304 | 53,M,ASY,125,0,1,Normal,120,N,1.5,Up,1 305 | 62,F,ASY,120,0,1,ST,123,Y,1.7,Down,1 306 | 51,M,ASY,95,0,1,Normal,126,N,2.2,Flat,1 307 | 51,F,ASY,120,0,1,Normal,127,Y,1.5,Up,1 308 | 55,M,ASY,115,0,1,Normal,155,N,0.1,Flat,1 309 | 53,M,ATA,130,0,0,ST,120,N,0.7,Down,0 310 | 58,M,ASY,115,0,1,Normal,138,N,0.5,Up,1 311 | 57,M,ASY,95,0,1,Normal,182,N,0.7,Down,1 312 | 65,M,ASY,155,0,0,Normal,154,N,1,Up,0 313 | 60,M,ASY,125,0,1,Normal,110,N,0.1,Up,1 314 | 41,M,ASY,125,0,1,Normal,176,N,1.6,Up,1 315 | 34,M,ASY,115,0,1,Normal,154,N,0.2,Up,1 316 | 53,M,ASY,80,0,0,Normal,141,Y,2,Down,0 317 | 74,M,ATA,145,0,1,ST,123,N,1.3,Up,1 318 | 57,M,NAP,105,0,1,Normal,148,N,0.3,Flat,1 319 | 56,M,ASY,140,0,1,Normal,121,Y,1.8,Up,1 320 | 61,M,ASY,130,0,1,Normal,77,N,2.5,Flat,1 321 | 68,M,ASY,145,0,1,Normal,136,N,1.8,Up,1 322 | 59,M,NAP,125,0,1,Normal,175,N,2.6,Flat,1 323 | 63,M,ASY,100,0,1,Normal,109,N,-0.9,Flat,1 324 | 38,F,ASY,105,0,1,Normal,166,N,2.8,Up,1 325 | 62,M,ASY,115,0,1,Normal,128,Y,2.5,Down,1 326 | 46,M,ASY,100,0,1,ST,133,N,-2.6,Flat,1 327 | 42,M,ASY,105,0,1,Normal,128,Y,-1.5,Down,1 328 | 45,M,NAP,110,0,0,Normal,138,N,-0.1,Up,0 329 | 59,M,ASY,125,0,1,Normal,119,Y,0.9,Up,1 330 | 52,M,ASY,95,0,1,Normal,82,Y,0.8,Flat,1 331 | 60,M,ASY,130,0,1,ST,130,Y,1.1,Down,1 332 | 60,M,NAP,115,0,1,Normal,143,N,2.4,Up,1 333 | 56,M,ASY,115,0,1,ST,82,N,-1,Up,1 334 | 38,M,NAP,100,0,0,Normal,179,N,-1.1,Up,0 335 | 40,M,ASY,95,0,1,ST,144,N,0,Up,1 336 | 51,M,ASY,130,0,1,Normal,170,N,-0.7,Up,1 337 | 62,M,TA,120,0,1,LVH,134,N,-0.8,Flat,1 338 | 72,M,NAP,160,0,0,LVH,114,N,1.6,Flat,0 339 | 63,M,ASY,150,0,1,ST,154,N,3.7,Up,1 340 | 63,M,ASY,140,0,1,LVH,149,N,2,Up,1 341 | 64,F,ASY,95,0,1,Normal,145,N,1.1,Down,1 342 | 43,M,ASY,100,0,1,Normal,122,N,1.5,Down,1 343 | 64,M,ASY,110,0,1,Normal,114,Y,1.3,Down,1 344 | 61,M,ASY,110,0,1,Normal,113,N,1.4,Flat,1 345 | 52,M,ASY,130,0,1,Normal,120,N,0,Flat,1 346 | 51,M,ASY,120,0,1,Normal,104,N,0,Flat,1 347 | 69,M,ASY,135,0,0,Normal,130,N,0,Flat,1 348 | 59,M,ASY,120,0,0,Normal,115,N,0,Flat,1 349 | 48,M,ASY,115,0,1,Normal,128,N,0,Flat,1 350 | 69,M,ASY,137,0,0,ST,104,Y,1.6,Flat,1 351 | 36,M,ASY,110,0,1,Normal,125,Y,1,Flat,1 352 | 53,M,ASY,120,0,1,Normal,120,N,0,Flat,1 353 | 43,M,ASY,140,0,0,ST,140,Y,0.5,Up,1 354 | 56,M,ASY,120,0,0,ST,100,Y,-1,Down,1 355 | 58,M,ASY,130,0,0,ST,100,Y,1,Flat,1 356 | 55,M,ASY,120,0,0,ST,92,N,0.3,Up,1 357 | 67,M,TA,145,0,0,LVH,125,N,0,Flat,1 358 | 46,M,ASY,115,0,0,Normal,113,Y,1.5,Flat,1 359 | 53,M,ATA,120,0,0,Normal,95,N,0,Flat,1 360 | 38,M,NAP,115,0,0,Normal,128,Y,0,Flat,1 361 | 53,M,NAP,105,0,0,Normal,115,N,0,Flat,1 362 | 62,M,NAP,160,0,0,Normal,72,Y,0,Flat,1 363 | 47,M,ASY,160,0,0,Normal,124,Y,0,Flat,1 364 | 56,M,NAP,155,0,0,ST,99,N,0,Flat,1 365 | 56,M,ASY,120,0,0,ST,148,N,0,Flat,1 366 | 56,M,NAP,120,0,0,Normal,97,N,0,Flat,0 367 | 64,F,ASY,200,0,0,Normal,140,Y,1,Flat,1 368 | 61,M,ASY,150,0,0,Normal,117,Y,2,Flat,1 369 | 68,M,ASY,135,0,0,ST,120,Y,0,Up,1 370 | 57,M,ASY,140,0,0,Normal,120,Y,2,Flat,1 371 | 63,M,ASY,150,0,0,Normal,86,Y,2,Flat,1 372 | 60,M,ASY,135,0,0,Normal,63,Y,0.5,Up,1 373 | 66,M,ASY,150,0,0,Normal,108,Y,2,Flat,1 374 | 63,M,ASY,185,0,0,Normal,98,Y,0,Up,1 375 | 59,M,ASY,135,0,0,Normal,115,Y,1,Flat,1 376 | 61,M,ASY,125,0,0,Normal,105,Y,0,Down,1 377 | 73,F,NAP,160,0,0,ST,121,N,0,Up,1 378 | 47,M,NAP,155,0,0,Normal,118,Y,1,Flat,1 379 | 65,M,ASY,160,0,1,ST,122,N,1.2,Flat,1 380 | 70,M,ASY,140,0,1,Normal,157,Y,2,Flat,1 381 | 50,M,ASY,120,0,0,ST,156,Y,0,Up,1 382 | 60,M,ASY,160,0,0,ST,99,Y,0.5,Flat,1 383 | 50,M,ASY,115,0,0,Normal,120,Y,0.5,Flat,1 384 | 43,M,ASY,115,0,0,Normal,145,Y,2,Flat,1 385 | 38,F,ASY,110,0,0,Normal,156,N,0,Flat,1 386 | 54,M,ASY,120,0,0,Normal,155,N,0,Flat,1 387 | 61,M,ASY,150,0,0,Normal,105,Y,0,Flat,1 388 | 42,M,ASY,145,0,0,Normal,99,Y,0,Flat,1 389 | 53,M,ASY,130,0,0,LVH,135,Y,1,Flat,1 390 | 55,M,ASY,140,0,0,Normal,83,N,0,Flat,1 391 | 61,M,ASY,160,0,1,ST,145,N,1,Flat,1 392 | 51,M,ASY,140,0,0,Normal,60,N,0,Flat,1 393 | 70,M,ASY,115,0,0,ST,92,Y,0,Flat,1 394 | 61,M,ASY,130,0,0,LVH,115,N,0,Flat,1 395 | 38,M,ASY,150,0,1,Normal,120,Y,0.7,Flat,1 396 | 57,M,ASY,160,0,1,Normal,98,Y,2,Flat,1 397 | 38,M,ASY,135,0,1,Normal,150,N,0,Flat,1 398 | 62,F,TA,140,0,1,Normal,143,N,0,Flat,1 399 | 58,M,ASY,170,0,1,ST,105,Y,0,Flat,1 400 | 52,M,ASY,165,0,1,Normal,122,Y,1,Up,1 401 | 61,M,NAP,200,0,1,ST,70,N,0,Flat,1 402 | 50,F,ASY,160,0,1,Normal,110,N,0,Flat,1 403 | 51,M,ASY,130,0,1,ST,163,N,0,Flat,1 404 | 65,M,ASY,145,0,1,ST,67,N,0.7,Flat,1 405 | 52,M,ASY,135,0,1,Normal,128,Y,2,Flat,1 406 | 47,M,NAP,110,0,1,Normal,120,Y,0,Flat,1 407 | 35,M,ASY,120,0,1,Normal,130,Y,1.2,Flat,1 408 | 57,M,ASY,140,0,1,Normal,100,Y,0,Flat,1 409 | 62,M,ASY,115,0,1,Normal,72,Y,-0.5,Flat,1 410 | 59,M,ASY,110,0,1,Normal,94,N,0,Flat,1 411 | 53,M,NAP,160,0,1,LVH,122,Y,0,Flat,1 412 | 62,M,ASY,150,0,1,ST,78,N,2,Flat,1 413 | 54,M,ASY,180,0,1,Normal,150,N,1.5,Flat,1 414 | 56,M,ASY,125,0,1,Normal,103,Y,1,Flat,1 415 | 56,M,NAP,125,0,1,Normal,98,N,-2,Flat,1 416 | 54,M,ASY,130,0,1,Normal,110,Y,3,Flat,1 417 | 66,F,ASY,155,0,1,Normal,90,N,0,Flat,1 418 | 63,M,ASY,140,260,0,ST,112,Y,3,Flat,1 419 | 44,M,ASY,130,209,0,ST,127,N,0,Up,0 420 | 60,M,ASY,132,218,0,ST,140,Y,1.5,Down,1 421 | 55,M,ASY,142,228,0,ST,149,Y,2.5,Up,1 422 | 66,M,NAP,110,213,1,LVH,99,Y,1.3,Flat,0 423 | 66,M,NAP,120,0,0,ST,120,N,-0.5,Up,0 424 | 65,M,ASY,150,236,1,ST,105,Y,0,Flat,1 425 | 60,M,NAP,180,0,0,ST,140,Y,1.5,Flat,0 426 | 60,M,NAP,120,0,1,Normal,141,Y,2,Up,1 427 | 60,M,ATA,160,267,1,ST,157,N,0.5,Flat,1 428 | 56,M,ATA,126,166,0,ST,140,N,0,Up,0 429 | 59,M,ASY,140,0,0,ST,117,Y,1,Flat,1 430 | 62,M,ASY,110,0,0,Normal,120,Y,0.5,Flat,1 431 | 63,M,NAP,133,0,0,LVH,120,Y,1,Flat,1 432 | 57,M,ASY,128,0,1,ST,148,Y,1,Flat,1 433 | 62,M,ASY,120,220,0,ST,86,N,0,Up,0 434 | 63,M,ASY,170,177,0,Normal,84,Y,2.5,Down,1 435 | 46,M,ASY,110,236,0,Normal,125,Y,2,Flat,1 436 | 63,M,ASY,126,0,0,ST,120,N,1.5,Down,0 437 | 60,M,ASY,152,0,0,ST,118,Y,0,Up,0 438 | 58,M,ASY,116,0,0,Normal,124,N,1,Up,1 439 | 64,M,ASY,120,0,1,ST,106,N,2,Flat,1 440 | 63,M,NAP,130,0,0,ST,111,Y,0,Flat,1 441 | 74,M,NAP,138,0,0,Normal,116,N,0.2,Up,0 442 | 52,M,NAP,128,0,0,ST,180,N,3,Up,1 443 | 69,M,ASY,130,0,1,ST,129,N,1,Flat,1 444 | 51,M,ASY,128,0,1,ST,125,Y,1.2,Flat,1 445 | 60,M,ASY,130,186,1,ST,140,Y,0.5,Flat,1 446 | 56,M,ASY,120,100,0,Normal,120,Y,1.5,Flat,1 447 | 55,M,NAP,136,228,0,ST,124,Y,1.6,Flat,1 448 | 54,M,ASY,130,0,0,ST,117,Y,1.4,Flat,1 449 | 77,M,ASY,124,171,0,ST,110,Y,2,Up,1 450 | 63,M,ASY,160,230,1,Normal,105,Y,1,Flat,1 451 | 55,M,NAP,0,0,0,Normal,155,N,1.5,Flat,1 452 | 52,M,NAP,122,0,0,Normal,110,Y,2,Down,1 453 | 64,M,ASY,144,0,0,ST,122,Y,1,Flat,1 454 | 60,M,ASY,140,281,0,ST,118,Y,1.5,Flat,1 455 | 60,M,ASY,120,0,0,Normal,133,Y,2,Up,0 456 | 58,M,ASY,136,203,1,Normal,123,Y,1.2,Flat,1 457 | 59,M,ASY,154,0,0,ST,131,Y,1.5,Up,0 458 | 61,M,NAP,120,0,0,Normal,80,Y,0,Flat,1 459 | 40,M,ASY,125,0,1,Normal,165,N,0,Flat,1 460 | 61,M,ASY,134,0,1,ST,86,N,1.5,Flat,1 461 | 41,M,ASY,104,0,0,ST,111,N,0,Up,0 462 | 57,M,ASY,139,277,1,ST,118,Y,1.9,Flat,1 463 | 63,M,ASY,136,0,0,Normal,84,Y,0,Flat,1 464 | 59,M,ASY,122,233,0,Normal,117,Y,1.3,Down,1 465 | 51,M,ASY,128,0,0,Normal,107,N,0,Up,0 466 | 59,M,NAP,131,0,0,Normal,128,Y,2,Down,1 467 | 42,M,NAP,134,240,0,Normal,160,N,0,Up,0 468 | 55,M,NAP,120,0,0,ST,125,Y,2.5,Flat,1 469 | 63,F,ATA,132,0,0,Normal,130,N,0.1,Up,0 470 | 62,M,ASY,152,153,0,ST,97,Y,1.6,Up,1 471 | 56,M,ATA,124,224,1,Normal,161,N,2,Flat,0 472 | 53,M,ASY,126,0,0,Normal,106,N,0,Flat,1 473 | 68,M,ASY,138,0,0,Normal,130,Y,3,Flat,1 474 | 53,M,ASY,154,0,1,ST,140,Y,1.5,Flat,1 475 | 60,M,NAP,141,316,1,ST,122,Y,1.7,Flat,1 476 | 62,M,ATA,131,0,0,Normal,130,N,0.1,Up,0 477 | 59,M,ASY,178,0,1,LVH,120,Y,0,Flat,1 478 | 51,M,ASY,132,218,1,LVH,139,N,0.1,Up,0 479 | 61,M,ASY,110,0,1,Normal,108,Y,2,Down,1 480 | 57,M,ASY,130,311,1,ST,148,Y,2,Flat,1 481 | 56,M,NAP,170,0,0,LVH,123,Y,2.5,Flat,1 482 | 58,M,ATA,126,0,1,Normal,110,Y,2,Flat,1 483 | 69,M,NAP,140,0,1,ST,118,N,2.5,Down,1 484 | 67,M,TA,142,270,1,Normal,125,N,2.5,Up,1 485 | 58,M,ASY,120,0,0,LVH,106,Y,1.5,Down,1 486 | 65,M,ASY,134,0,0,Normal,112,Y,1.1,Flat,1 487 | 63,M,ATA,139,217,1,ST,128,Y,1.2,Flat,1 488 | 55,M,ATA,110,214,1,ST,180,N,0.4,Up,0 489 | 57,M,ASY,140,214,0,ST,144,Y,2,Flat,1 490 | 65,M,TA,140,252,0,Normal,135,N,0.3,Up,0 491 | 54,M,ASY,136,220,0,Normal,140,Y,3,Flat,1 492 | 72,M,NAP,120,214,0,Normal,102,Y,1,Flat,1 493 | 75,M,ASY,170,203,1,ST,108,N,0,Flat,1 494 | 49,M,TA,130,0,0,ST,145,N,3,Flat,1 495 | 51,M,NAP,137,339,0,Normal,127,Y,1.7,Flat,1 496 | 60,M,ASY,142,216,0,Normal,110,Y,2.5,Flat,1 497 | 64,F,ASY,142,276,0,Normal,140,Y,1,Flat,1 498 | 58,M,ASY,132,458,1,Normal,69,N,1,Down,0 499 | 61,M,ASY,146,241,0,Normal,148,Y,3,Down,1 500 | 67,M,ASY,160,384,1,ST,130,Y,0,Flat,1 501 | 62,M,ASY,135,297,0,Normal,130,Y,1,Flat,1 502 | 65,M,ASY,136,248,0,Normal,140,Y,4,Down,1 503 | 63,M,ASY,130,308,0,Normal,138,Y,2,Flat,1 504 | 69,M,ASY,140,208,0,ST,140,Y,2,Flat,1 505 | 51,M,ASY,132,227,1,ST,138,N,0.2,Up,0 506 | 62,M,ASY,158,210,1,Normal,112,Y,3,Down,1 507 | 55,M,NAP,136,245,1,ST,131,Y,1.2,Flat,1 508 | 75,M,ASY,136,225,0,Normal,112,Y,3,Flat,1 509 | 40,M,NAP,106,240,0,Normal,80,Y,0,Up,0 510 | 67,M,ASY,120,0,1,Normal,150,N,1.5,Down,1 511 | 58,M,ASY,110,198,0,Normal,110,N,0,Flat,1 512 | 60,M,ASY,136,195,0,Normal,126,N,0.3,Up,0 513 | 63,M,ASY,160,267,1,ST,88,Y,2,Flat,1 514 | 35,M,NAP,123,161,0,ST,153,N,-0.1,Up,0 515 | 62,M,TA,112,258,0,ST,150,Y,1.3,Flat,1 516 | 43,M,ASY,122,0,0,Normal,120,N,0.5,Up,1 517 | 63,M,NAP,130,0,1,ST,160,N,3,Flat,0 518 | 68,M,NAP,150,195,1,Normal,132,N,0,Flat,1 519 | 65,M,ASY,150,235,0,Normal,120,Y,1.5,Flat,1 520 | 48,M,NAP,102,0,1,ST,110,Y,1,Down,1 521 | 63,M,ASY,96,305,0,ST,121,Y,1,Up,1 522 | 64,M,ASY,130,223,0,ST,128,N,0.5,Flat,0 523 | 61,M,ASY,120,282,0,ST,135,Y,4,Down,1 524 | 50,M,ASY,144,349,0,LVH,120,Y,1,Up,1 525 | 59,M,ASY,124,160,0,Normal,117,Y,1,Flat,1 526 | 55,M,ASY,150,160,0,ST,150,N,0,Up,0 527 | 45,M,NAP,130,236,0,Normal,144,N,0.1,Up,0 528 | 65,M,ASY,144,312,0,LVH,113,Y,1.7,Flat,1 529 | 61,M,ATA,139,283,0,Normal,135,N,0.3,Up,0 530 | 49,M,NAP,131,142,0,Normal,127,Y,1.5,Flat,1 531 | 72,M,ASY,143,211,0,Normal,109,Y,1.4,Flat,1 532 | 50,M,ASY,133,218,0,Normal,128,Y,1.1,Flat,1 533 | 64,M,ASY,143,306,1,ST,115,Y,1.8,Flat,1 534 | 55,M,ASY,116,186,1,ST,102,N,0,Flat,1 535 | 63,M,ASY,110,252,0,ST,140,Y,2,Flat,1 536 | 59,M,ASY,125,222,0,Normal,135,Y,2.5,Down,1 537 | 56,M,ASY,130,0,0,LVH,122,Y,1,Flat,1 538 | 62,M,NAP,133,0,1,ST,119,Y,1.2,Flat,1 539 | 74,M,ASY,150,258,1,ST,130,Y,4,Down,1 540 | 54,M,ASY,130,202,1,Normal,112,Y,2,Flat,1 541 | 57,M,ASY,110,197,0,LVH,100,N,0,Up,0 542 | 62,M,NAP,138,204,0,ST,122,Y,1.2,Flat,1 543 | 76,M,NAP,104,113,0,LVH,120,N,3.5,Down,1 544 | 54,F,ASY,138,274,0,Normal,105,Y,1.5,Flat,1 545 | 70,M,ASY,170,192,0,ST,129,Y,3,Down,1 546 | 61,F,ATA,140,298,1,Normal,120,Y,0,Up,0 547 | 48,M,ASY,132,272,0,ST,139,N,0.2,Up,0 548 | 48,M,NAP,132,220,1,ST,162,N,0,Flat,1 549 | 61,M,TA,142,200,1,ST,100,N,1.5,Down,1 550 | 66,M,ASY,112,261,0,Normal,140,N,1.5,Up,1 551 | 68,M,TA,139,181,1,ST,135,N,0.2,Up,0 552 | 55,M,ASY,172,260,0,Normal,73,N,2,Flat,1 553 | 62,M,NAP,120,220,0,LVH,86,N,0,Up,0 554 | 71,M,NAP,144,221,0,Normal,108,Y,1.8,Flat,1 555 | 74,M,TA,145,216,1,Normal,116,Y,1.8,Flat,1 556 | 53,M,NAP,155,175,1,ST,160,N,0.3,Up,0 557 | 58,M,NAP,150,219,0,ST,118,Y,0,Flat,1 558 | 75,M,ASY,160,310,1,Normal,112,Y,2,Down,0 559 | 56,M,NAP,137,208,1,ST,122,Y,1.8,Flat,1 560 | 58,M,NAP,137,232,0,ST,124,Y,1.4,Flat,1 561 | 64,M,ASY,134,273,0,Normal,102,Y,4,Down,1 562 | 54,M,NAP,133,203,0,ST,137,N,0.2,Up,0 563 | 54,M,ATA,132,182,0,ST,141,N,0.1,Up,0 564 | 59,M,ASY,140,274,0,Normal,154,Y,2,Flat,0 565 | 55,M,ASY,135,204,1,ST,126,Y,1.1,Flat,1 566 | 57,M,ASY,144,270,1,ST,160,Y,2,Flat,1 567 | 61,M,ASY,141,292,0,ST,115,Y,1.7,Flat,1 568 | 41,M,ASY,150,171,0,Normal,128,Y,1.5,Flat,0 569 | 71,M,ASY,130,221,0,ST,115,Y,0,Flat,1 570 | 38,M,ASY,110,289,0,Normal,105,Y,1.5,Down,1 571 | 55,M,ASY,158,217,0,Normal,110,Y,2.5,Flat,1 572 | 56,M,ASY,128,223,0,ST,119,Y,2,Down,1 573 | 69,M,ASY,140,110,1,Normal,109,Y,1.5,Flat,1 574 | 64,M,ASY,150,193,0,ST,135,Y,0.5,Flat,1 575 | 72,M,ASY,160,123,1,LVH,130,N,1.5,Flat,1 576 | 69,M,ASY,142,210,1,ST,112,Y,1.5,Flat,1 577 | 56,M,ASY,137,282,1,Normal,126,Y,1.2,Flat,1 578 | 62,M,ASY,139,170,0,ST,120,Y,3,Flat,1 579 | 67,M,ASY,146,369,0,Normal,110,Y,1.9,Flat,1 580 | 57,M,ASY,156,173,0,LVH,119,Y,3,Down,1 581 | 69,M,ASY,145,289,1,ST,110,Y,1.8,Flat,1 582 | 51,M,ASY,131,152,1,LVH,130,Y,1,Flat,1 583 | 48,M,ASY,140,208,0,Normal,159,Y,1.5,Up,1 584 | 69,M,ASY,122,216,1,LVH,84,Y,0,Flat,1 585 | 69,M,NAP,142,271,0,LVH,126,N,0.3,Up,0 586 | 64,M,ASY,141,244,1,ST,116,Y,1.5,Flat,1 587 | 57,M,ATA,180,285,1,ST,120,N,0.8,Flat,1 588 | 53,M,ASY,124,243,0,Normal,122,Y,2,Flat,1 589 | 37,M,NAP,118,240,0,LVH,165,N,1,Flat,0 590 | 67,M,ASY,140,219,0,ST,122,Y,2,Flat,1 591 | 74,M,NAP,140,237,1,Normal,94,N,0,Flat,1 592 | 63,M,ATA,136,165,0,ST,133,N,0.2,Up,0 593 | 58,M,ASY,100,213,0,ST,110,N,0,Up,0 594 | 61,M,ASY,190,287,1,LVH,150,Y,2,Down,1 595 | 64,M,ASY,130,258,1,LVH,130,N,0,Flat,1 596 | 58,M,ASY,160,256,1,LVH,113,Y,1,Up,1 597 | 60,M,ASY,130,186,1,LVH,140,Y,0.5,Flat,1 598 | 57,M,ASY,122,264,0,LVH,100,N,0,Flat,1 599 | 55,M,NAP,133,185,0,ST,136,N,0.2,Up,0 600 | 55,M,ASY,120,226,0,LVH,127,Y,1.7,Down,1 601 | 56,M,ASY,130,203,1,Normal,98,N,1.5,Flat,1 602 | 57,M,ASY,130,207,0,ST,96,Y,1,Flat,0 603 | 61,M,NAP,140,284,0,Normal,123,Y,1.3,Flat,1 604 | 61,M,NAP,120,337,0,Normal,98,Y,0,Flat,1 605 | 74,M,ASY,155,310,0,Normal,112,Y,1.5,Down,1 606 | 68,M,NAP,134,254,1,Normal,151,Y,0,Up,0 607 | 51,F,ASY,114,258,1,LVH,96,N,1,Up,0 608 | 62,M,ASY,160,254,1,ST,108,Y,3,Flat,1 609 | 53,M,ASY,144,300,1,ST,128,Y,1.5,Flat,1 610 | 62,M,ASY,158,170,0,ST,138,Y,0,Flat,1 611 | 46,M,ASY,134,310,0,Normal,126,N,0,Flat,1 612 | 54,F,ASY,127,333,1,ST,154,N,0,Flat,1 613 | 62,M,TA,135,139,0,ST,137,N,0.2,Up,0 614 | 55,M,ASY,122,223,1,ST,100,N,0,Flat,1 615 | 58,M,ASY,140,385,1,LVH,135,N,0.3,Up,0 616 | 62,M,ATA,120,254,0,LVH,93,Y,0,Flat,1 617 | 70,M,ASY,130,322,0,LVH,109,N,2.4,Flat,1 618 | 67,F,NAP,115,564,0,LVH,160,N,1.6,Flat,0 619 | 57,M,ATA,124,261,0,Normal,141,N,0.3,Up,1 620 | 64,M,ASY,128,263,0,Normal,105,Y,0.2,Flat,0 621 | 74,F,ATA,120,269,0,LVH,121,Y,0.2,Up,0 622 | 65,M,ASY,120,177,0,Normal,140,N,0.4,Up,0 623 | 56,M,NAP,130,256,1,LVH,142,Y,0.6,Flat,1 624 | 59,M,ASY,110,239,0,LVH,142,Y,1.2,Flat,1 625 | 60,M,ASY,140,293,0,LVH,170,N,1.2,Flat,1 626 | 63,F,ASY,150,407,0,LVH,154,N,4,Flat,1 627 | 59,M,ASY,135,234,0,Normal,161,N,0.5,Flat,0 628 | 53,M,ASY,142,226,0,LVH,111,Y,0,Up,0 629 | 44,M,NAP,140,235,0,LVH,180,N,0,Up,0 630 | 61,M,TA,134,234,0,Normal,145,N,2.6,Flat,1 631 | 57,F,ASY,128,303,0,LVH,159,N,0,Up,0 632 | 71,F,ASY,112,149,0,Normal,125,N,1.6,Flat,0 633 | 46,M,ASY,140,311,0,Normal,120,Y,1.8,Flat,1 634 | 53,M,ASY,140,203,1,LVH,155,Y,3.1,Down,1 635 | 64,M,TA,110,211,0,LVH,144,Y,1.8,Flat,0 636 | 40,M,TA,140,199,0,Normal,178,Y,1.4,Up,0 637 | 67,M,ASY,120,229,0,LVH,129,Y,2.6,Flat,1 638 | 48,M,ATA,130,245,0,LVH,180,N,0.2,Flat,0 639 | 43,M,ASY,115,303,0,Normal,181,N,1.2,Flat,0 640 | 47,M,ASY,112,204,0,Normal,143,N,0.1,Up,0 641 | 54,F,ATA,132,288,1,LVH,159,Y,0,Up,0 642 | 48,F,NAP,130,275,0,Normal,139,N,0.2,Up,0 643 | 46,F,ASY,138,243,0,LVH,152,Y,0,Flat,0 644 | 51,F,NAP,120,295,0,LVH,157,N,0.6,Up,0 645 | 58,M,NAP,112,230,0,LVH,165,N,2.5,Flat,1 646 | 71,F,NAP,110,265,1,LVH,130,N,0,Up,0 647 | 57,M,NAP,128,229,0,LVH,150,N,0.4,Flat,1 648 | 66,M,ASY,160,228,0,LVH,138,N,2.3,Up,0 649 | 37,F,NAP,120,215,0,Normal,170,N,0,Up,0 650 | 59,M,ASY,170,326,0,LVH,140,Y,3.4,Down,1 651 | 50,M,ASY,144,200,0,LVH,126,Y,0.9,Flat,1 652 | 48,M,ASY,130,256,1,LVH,150,Y,0,Up,1 653 | 61,M,ASY,140,207,0,LVH,138,Y,1.9,Up,1 654 | 59,M,TA,160,273,0,LVH,125,N,0,Up,1 655 | 42,M,NAP,130,180,0,Normal,150,N,0,Up,0 656 | 48,M,ASY,122,222,0,LVH,186,N,0,Up,0 657 | 40,M,ASY,152,223,0,Normal,181,N,0,Up,1 658 | 62,F,ASY,124,209,0,Normal,163,N,0,Up,0 659 | 44,M,NAP,130,233,0,Normal,179,Y,0.4,Up,0 660 | 46,M,ATA,101,197,1,Normal,156,N,0,Up,0 661 | 59,M,NAP,126,218,1,Normal,134,N,2.2,Flat,1 662 | 58,M,NAP,140,211,1,LVH,165,N,0,Up,0 663 | 49,M,NAP,118,149,0,LVH,126,N,0.8,Up,1 664 | 44,M,ASY,110,197,0,LVH,177,N,0,Up,1 665 | 66,M,ATA,160,246,0,Normal,120,Y,0,Flat,1 666 | 65,F,ASY,150,225,0,LVH,114,N,1,Flat,1 667 | 42,M,ASY,136,315,0,Normal,125,Y,1.8,Flat,1 668 | 52,M,ATA,128,205,1,Normal,184,N,0,Up,0 669 | 65,F,NAP,140,417,1,LVH,157,N,0.8,Up,0 670 | 63,F,ATA,140,195,0,Normal,179,N,0,Up,0 671 | 45,F,ATA,130,234,0,LVH,175,N,0.6,Flat,0 672 | 41,F,ATA,105,198,0,Normal,168,N,0,Up,0 673 | 61,M,ASY,138,166,0,LVH,125,Y,3.6,Flat,1 674 | 60,F,NAP,120,178,1,Normal,96,N,0,Up,0 675 | 59,F,ASY,174,249,0,Normal,143,Y,0,Flat,1 676 | 62,M,ATA,120,281,0,LVH,103,N,1.4,Flat,1 677 | 57,M,NAP,150,126,1,Normal,173,N,0.2,Up,0 678 | 51,F,ASY,130,305,0,Normal,142,Y,1.2,Flat,1 679 | 44,M,NAP,120,226,0,Normal,169,N,0,Up,0 680 | 60,F,TA,150,240,0,Normal,171,N,0.9,Up,0 681 | 63,M,TA,145,233,1,LVH,150,N,2.3,Down,0 682 | 57,M,ASY,150,276,0,LVH,112,Y,0.6,Flat,1 683 | 51,M,ASY,140,261,0,LVH,186,Y,0,Up,0 684 | 58,F,ATA,136,319,1,LVH,152,N,0,Up,1 685 | 44,F,NAP,118,242,0,Normal,149,N,0.3,Flat,0 686 | 47,M,NAP,108,243,0,Normal,152,N,0,Up,1 687 | 61,M,ASY,120,260,0,Normal,140,Y,3.6,Flat,1 688 | 57,F,ASY,120,354,0,Normal,163,Y,0.6,Up,0 689 | 70,M,ATA,156,245,0,LVH,143,N,0,Up,0 690 | 76,F,NAP,140,197,0,ST,116,N,1.1,Flat,0 691 | 67,F,ASY,106,223,0,Normal,142,N,0.3,Up,0 692 | 45,M,ASY,142,309,0,LVH,147,Y,0,Flat,1 693 | 45,M,ASY,104,208,0,LVH,148,Y,3,Flat,0 694 | 39,F,NAP,94,199,0,Normal,179,N,0,Up,0 695 | 42,F,NAP,120,209,0,Normal,173,N,0,Flat,0 696 | 56,M,ATA,120,236,0,Normal,178,N,0.8,Up,0 697 | 58,M,ASY,146,218,0,Normal,105,N,2,Flat,1 698 | 35,M,ASY,120,198,0,Normal,130,Y,1.6,Flat,1 699 | 58,M,ASY,150,270,0,LVH,111,Y,0.8,Up,1 700 | 41,M,NAP,130,214,0,LVH,168,N,2,Flat,0 701 | 57,M,ASY,110,201,0,Normal,126,Y,1.5,Flat,0 702 | 42,M,TA,148,244,0,LVH,178,N,0.8,Up,0 703 | 62,M,ATA,128,208,1,LVH,140,N,0,Up,0 704 | 59,M,TA,178,270,0,LVH,145,N,4.2,Down,0 705 | 41,F,ATA,126,306,0,Normal,163,N,0,Up,0 706 | 50,M,ASY,150,243,0,LVH,128,N,2.6,Flat,1 707 | 59,M,ATA,140,221,0,Normal,164,Y,0,Up,0 708 | 61,F,ASY,130,330,0,LVH,169,N,0,Up,1 709 | 54,M,ASY,124,266,0,LVH,109,Y,2.2,Flat,1 710 | 54,M,ASY,110,206,0,LVH,108,Y,0,Flat,1 711 | 52,M,ASY,125,212,0,Normal,168,N,1,Up,1 712 | 47,M,ASY,110,275,0,LVH,118,Y,1,Flat,1 713 | 66,M,ASY,120,302,0,LVH,151,N,0.4,Flat,0 714 | 58,M,ASY,100,234,0,Normal,156,N,0.1,Up,1 715 | 64,F,NAP,140,313,0,Normal,133,N,0.2,Up,0 716 | 50,F,ATA,120,244,0,Normal,162,N,1.1,Up,0 717 | 44,F,NAP,108,141,0,Normal,175,N,0.6,Flat,0 718 | 67,M,ASY,120,237,0,Normal,71,N,1,Flat,1 719 | 49,F,ASY,130,269,0,Normal,163,N,0,Up,0 720 | 57,M,ASY,165,289,1,LVH,124,N,1,Flat,1 721 | 63,M,ASY,130,254,0,LVH,147,N,1.4,Flat,1 722 | 48,M,ASY,124,274,0,LVH,166,N,0.5,Flat,1 723 | 51,M,NAP,100,222,0,Normal,143,Y,1.2,Flat,0 724 | 60,F,ASY,150,258,0,LVH,157,N,2.6,Flat,1 725 | 59,M,ASY,140,177,0,Normal,162,Y,0,Up,1 726 | 45,F,ATA,112,160,0,Normal,138,N,0,Flat,0 727 | 55,F,ASY,180,327,0,ST,117,Y,3.4,Flat,1 728 | 41,M,ATA,110,235,0,Normal,153,N,0,Up,0 729 | 60,F,ASY,158,305,0,LVH,161,N,0,Up,1 730 | 54,F,NAP,135,304,1,Normal,170,N,0,Up,0 731 | 42,M,ATA,120,295,0,Normal,162,N,0,Up,0 732 | 49,F,ATA,134,271,0,Normal,162,N,0,Flat,0 733 | 46,M,ASY,120,249,0,LVH,144,N,0.8,Up,1 734 | 56,F,ASY,200,288,1,LVH,133,Y,4,Down,1 735 | 66,F,TA,150,226,0,Normal,114,N,2.6,Down,0 736 | 56,M,ASY,130,283,1,LVH,103,Y,1.6,Down,1 737 | 49,M,NAP,120,188,0,Normal,139,N,2,Flat,1 738 | 54,M,ASY,122,286,0,LVH,116,Y,3.2,Flat,1 739 | 57,M,ASY,152,274,0,Normal,88,Y,1.2,Flat,1 740 | 65,F,NAP,160,360,0,LVH,151,N,0.8,Up,0 741 | 54,M,NAP,125,273,0,LVH,152,N,0.5,Down,0 742 | 54,F,NAP,160,201,0,Normal,163,N,0,Up,0 743 | 62,M,ASY,120,267,0,Normal,99,Y,1.8,Flat,1 744 | 52,F,NAP,136,196,0,LVH,169,N,0.1,Flat,0 745 | 52,M,ATA,134,201,0,Normal,158,N,0.8,Up,0 746 | 60,M,ASY,117,230,1,Normal,160,Y,1.4,Up,1 747 | 63,F,ASY,108,269,0,Normal,169,Y,1.8,Flat,1 748 | 66,M,ASY,112,212,0,LVH,132,Y,0.1,Up,1 749 | 42,M,ASY,140,226,0,Normal,178,N,0,Up,0 750 | 64,M,ASY,120,246,0,LVH,96,Y,2.2,Down,1 751 | 54,M,NAP,150,232,0,LVH,165,N,1.6,Up,0 752 | 46,F,NAP,142,177,0,LVH,160,Y,1.4,Down,0 753 | 67,F,NAP,152,277,0,Normal,172,N,0,Up,0 754 | 56,M,ASY,125,249,1,LVH,144,Y,1.2,Flat,1 755 | 34,F,ATA,118,210,0,Normal,192,N,0.7,Up,0 756 | 57,M,ASY,132,207,0,Normal,168,Y,0,Up,0 757 | 64,M,ASY,145,212,0,LVH,132,N,2,Flat,1 758 | 59,M,ASY,138,271,0,LVH,182,N,0,Up,0 759 | 50,M,NAP,140,233,0,Normal,163,N,0.6,Flat,1 760 | 51,M,TA,125,213,0,LVH,125,Y,1.4,Up,0 761 | 54,M,ATA,192,283,0,LVH,195,N,0,Up,1 762 | 53,M,ASY,123,282,0,Normal,95,Y,2,Flat,1 763 | 52,M,ASY,112,230,0,Normal,160,N,0,Up,1 764 | 40,M,ASY,110,167,0,LVH,114,Y,2,Flat,1 765 | 58,M,NAP,132,224,0,LVH,173,N,3.2,Up,1 766 | 41,F,NAP,112,268,0,LVH,172,Y,0,Up,0 767 | 41,M,NAP,112,250,0,Normal,179,N,0,Up,0 768 | 50,F,NAP,120,219,0,Normal,158,N,1.6,Flat,0 769 | 54,F,NAP,108,267,0,LVH,167,N,0,Up,0 770 | 64,F,ASY,130,303,0,Normal,122,N,2,Flat,0 771 | 51,F,NAP,130,256,0,LVH,149,N,0.5,Up,0 772 | 46,F,ATA,105,204,0,Normal,172,N,0,Up,0 773 | 55,M,ASY,140,217,0,Normal,111,Y,5.6,Down,1 774 | 45,M,ATA,128,308,0,LVH,170,N,0,Up,0 775 | 56,M,TA,120,193,0,LVH,162,N,1.9,Flat,0 776 | 66,F,ASY,178,228,1,Normal,165,Y,1,Flat,1 777 | 38,M,TA,120,231,0,Normal,182,Y,3.8,Flat,1 778 | 62,F,ASY,150,244,0,Normal,154,Y,1.4,Flat,1 779 | 55,M,ATA,130,262,0,Normal,155,N,0,Up,0 780 | 58,M,ASY,128,259,0,LVH,130,Y,3,Flat,1 781 | 43,M,ASY,110,211,0,Normal,161,N,0,Up,0 782 | 64,F,ASY,180,325,0,Normal,154,Y,0,Up,0 783 | 50,F,ASY,110,254,0,LVH,159,N,0,Up,0 784 | 53,M,NAP,130,197,1,LVH,152,N,1.2,Down,0 785 | 45,F,ASY,138,236,0,LVH,152,Y,0.2,Flat,0 786 | 65,M,TA,138,282,1,LVH,174,N,1.4,Flat,1 787 | 69,M,TA,160,234,1,LVH,131,N,0.1,Flat,0 788 | 69,M,NAP,140,254,0,LVH,146,N,2,Flat,1 789 | 67,M,ASY,100,299,0,LVH,125,Y,0.9,Flat,1 790 | 68,F,NAP,120,211,0,LVH,115,N,1.5,Flat,0 791 | 34,M,TA,118,182,0,LVH,174,N,0,Up,0 792 | 62,F,ASY,138,294,1,Normal,106,N,1.9,Flat,1 793 | 51,M,ASY,140,298,0,Normal,122,Y,4.2,Flat,1 794 | 46,M,NAP,150,231,0,Normal,147,N,3.6,Flat,1 795 | 67,M,ASY,125,254,1,Normal,163,N,0.2,Flat,1 796 | 50,M,NAP,129,196,0,Normal,163,N,0,Up,0 797 | 42,M,NAP,120,240,1,Normal,194,N,0.8,Down,0 798 | 56,F,ASY,134,409,0,LVH,150,Y,1.9,Flat,1 799 | 41,M,ASY,110,172,0,LVH,158,N,0,Up,1 800 | 42,F,ASY,102,265,0,LVH,122,N,0.6,Flat,0 801 | 53,M,NAP,130,246,1,LVH,173,N,0,Up,0 802 | 43,M,NAP,130,315,0,Normal,162,N,1.9,Up,0 803 | 56,M,ASY,132,184,0,LVH,105,Y,2.1,Flat,1 804 | 52,M,ASY,108,233,1,Normal,147,N,0.1,Up,0 805 | 62,F,ASY,140,394,0,LVH,157,N,1.2,Flat,0 806 | 70,M,NAP,160,269,0,Normal,112,Y,2.9,Flat,1 807 | 54,M,ASY,140,239,0,Normal,160,N,1.2,Up,0 808 | 70,M,ASY,145,174,0,Normal,125,Y,2.6,Down,1 809 | 54,M,ATA,108,309,0,Normal,156,N,0,Up,0 810 | 35,M,ASY,126,282,0,LVH,156,Y,0,Up,1 811 | 48,M,NAP,124,255,1,Normal,175,N,0,Up,0 812 | 55,F,ATA,135,250,0,LVH,161,N,1.4,Flat,0 813 | 58,F,ASY,100,248,0,LVH,122,N,1,Flat,0 814 | 54,F,NAP,110,214,0,Normal,158,N,1.6,Flat,0 815 | 69,F,TA,140,239,0,Normal,151,N,1.8,Up,0 816 | 77,M,ASY,125,304,0,LVH,162,Y,0,Up,1 817 | 68,M,NAP,118,277,0,Normal,151,N,1,Up,0 818 | 58,M,ASY,125,300,0,LVH,171,N,0,Up,1 819 | 60,M,ASY,125,258,0,LVH,141,Y,2.8,Flat,1 820 | 51,M,ASY,140,299,0,Normal,173,Y,1.6,Up,1 821 | 55,M,ASY,160,289,0,LVH,145,Y,0.8,Flat,1 822 | 52,M,TA,152,298,1,Normal,178,N,1.2,Flat,0 823 | 60,F,NAP,102,318,0,Normal,160,N,0,Up,0 824 | 58,M,NAP,105,240,0,LVH,154,Y,0.6,Flat,0 825 | 64,M,NAP,125,309,0,Normal,131,Y,1.8,Flat,1 826 | 37,M,NAP,130,250,0,Normal,187,N,3.5,Down,0 827 | 59,M,TA,170,288,0,LVH,159,N,0.2,Flat,1 828 | 51,M,NAP,125,245,1,LVH,166,N,2.4,Flat,0 829 | 43,F,NAP,122,213,0,Normal,165,N,0.2,Flat,0 830 | 58,M,ASY,128,216,0,LVH,131,Y,2.2,Flat,1 831 | 29,M,ATA,130,204,0,LVH,202,N,0,Up,0 832 | 41,F,ATA,130,204,0,LVH,172,N,1.4,Up,0 833 | 63,F,NAP,135,252,0,LVH,172,N,0,Up,0 834 | 51,M,NAP,94,227,0,Normal,154,Y,0,Up,0 835 | 54,M,NAP,120,258,0,LVH,147,N,0.4,Flat,0 836 | 44,M,ATA,120,220,0,Normal,170,N,0,Up,0 837 | 54,M,ASY,110,239,0,Normal,126,Y,2.8,Flat,1 838 | 65,M,ASY,135,254,0,LVH,127,N,2.8,Flat,1 839 | 57,M,NAP,150,168,0,Normal,174,N,1.6,Up,0 840 | 63,M,ASY,130,330,1,LVH,132,Y,1.8,Up,1 841 | 35,F,ASY,138,183,0,Normal,182,N,1.4,Up,0 842 | 41,M,ATA,135,203,0,Normal,132,N,0,Flat,0 843 | 62,F,NAP,130,263,0,Normal,97,N,1.2,Flat,1 844 | 43,F,ASY,132,341,1,LVH,136,Y,3,Flat,1 845 | 58,F,TA,150,283,1,LVH,162,N,1,Up,0 846 | 52,M,TA,118,186,0,LVH,190,N,0,Flat,0 847 | 61,F,ASY,145,307,0,LVH,146,Y,1,Flat,1 848 | 39,M,ASY,118,219,0,Normal,140,N,1.2,Flat,1 849 | 45,M,ASY,115,260,0,LVH,185,N,0,Up,0 850 | 52,M,ASY,128,255,0,Normal,161,Y,0,Up,1 851 | 62,M,NAP,130,231,0,Normal,146,N,1.8,Flat,0 852 | 62,F,ASY,160,164,0,LVH,145,N,6.2,Down,1 853 | 53,F,ASY,138,234,0,LVH,160,N,0,Up,0 854 | 43,M,ASY,120,177,0,LVH,120,Y,2.5,Flat,1 855 | 47,M,NAP,138,257,0,LVH,156,N,0,Up,0 856 | 52,M,ATA,120,325,0,Normal,172,N,0.2,Up,0 857 | 68,M,NAP,180,274,1,LVH,150,Y,1.6,Flat,1 858 | 39,M,NAP,140,321,0,LVH,182,N,0,Up,0 859 | 53,F,ASY,130,264,0,LVH,143,N,0.4,Flat,0 860 | 62,F,ASY,140,268,0,LVH,160,N,3.6,Down,1 861 | 51,F,NAP,140,308,0,LVH,142,N,1.5,Up,0 862 | 60,M,ASY,130,253,0,Normal,144,Y,1.4,Up,1 863 | 65,M,ASY,110,248,0,LVH,158,N,0.6,Up,1 864 | 65,F,NAP,155,269,0,Normal,148,N,0.8,Up,0 865 | 60,M,NAP,140,185,0,LVH,155,N,3,Flat,1 866 | 60,M,ASY,145,282,0,LVH,142,Y,2.8,Flat,1 867 | 54,M,ASY,120,188,0,Normal,113,N,1.4,Flat,1 868 | 44,M,ATA,130,219,0,LVH,188,N,0,Up,0 869 | 44,M,ASY,112,290,0,LVH,153,N,0,Up,1 870 | 51,M,NAP,110,175,0,Normal,123,N,0.6,Up,0 871 | 59,M,NAP,150,212,1,Normal,157,N,1.6,Up,0 872 | 71,F,ATA,160,302,0,Normal,162,N,0.4,Up,0 873 | 61,M,NAP,150,243,1,Normal,137,Y,1,Flat,0 874 | 55,M,ASY,132,353,0,Normal,132,Y,1.2,Flat,1 875 | 64,M,NAP,140,335,0,Normal,158,N,0,Up,1 876 | 43,M,ASY,150,247,0,Normal,171,N,1.5,Up,0 877 | 58,F,NAP,120,340,0,Normal,172,N,0,Up,0 878 | 60,M,ASY,130,206,0,LVH,132,Y,2.4,Flat,1 879 | 58,M,ATA,120,284,0,LVH,160,N,1.8,Flat,1 880 | 49,M,ATA,130,266,0,Normal,171,N,0.6,Up,0 881 | 48,M,ATA,110,229,0,Normal,168,N,1,Down,1 882 | 52,M,NAP,172,199,1,Normal,162,N,0.5,Up,0 883 | 44,M,ATA,120,263,0,Normal,173,N,0,Up,0 884 | 56,F,ATA,140,294,0,LVH,153,N,1.3,Flat,0 885 | 57,M,ASY,140,192,0,Normal,148,N,0.4,Flat,0 886 | 67,M,ASY,160,286,0,LVH,108,Y,1.5,Flat,1 887 | 53,F,NAP,128,216,0,LVH,115,N,0,Up,0 888 | 52,M,NAP,138,223,0,Normal,169,N,0,Up,0 889 | 43,M,ASY,132,247,1,LVH,143,Y,0.1,Flat,1 890 | 52,M,ASY,128,204,1,Normal,156,Y,1,Flat,1 891 | 59,M,TA,134,204,0,Normal,162,N,0.8,Up,1 892 | 64,M,TA,170,227,0,LVH,155,N,0.6,Flat,0 893 | 66,F,NAP,146,278,0,LVH,152,N,0,Flat,0 894 | 39,F,NAP,138,220,0,Normal,152,N,0,Flat,0 895 | 57,M,ATA,154,232,0,LVH,164,N,0,Up,1 896 | 58,F,ASY,130,197,0,Normal,131,N,0.6,Flat,0 897 | 57,M,ASY,110,335,0,Normal,143,Y,3,Flat,1 898 | 47,M,NAP,130,253,0,Normal,179,N,0,Up,0 899 | 55,F,ASY,128,205,0,ST,130,Y,2,Flat,1 900 | 35,M,ATA,122,192,0,Normal,174,N,0,Up,0 901 | 61,M,ASY,148,203,0,Normal,161,N,0,Up,1 902 | 58,M,ASY,114,318,0,ST,140,N,4.4,Down,1 903 | 58,F,ASY,170,225,1,LVH,146,Y,2.8,Flat,1 904 | 58,M,ATA,125,220,0,Normal,144,N,0.4,Flat,0 905 | 56,M,ATA,130,221,0,LVH,163,N,0,Up,0 906 | 56,M,ATA,120,240,0,Normal,169,N,0,Down,0 907 | 67,M,NAP,152,212,0,LVH,150,N,0.8,Flat,1 908 | 55,F,ATA,132,342,0,Normal,166,N,1.2,Up,0 909 | 44,M,ASY,120,169,0,Normal,144,Y,2.8,Down,1 910 | 63,M,ASY,140,187,0,LVH,144,Y,4,Up,1 911 | 63,F,ASY,124,197,0,Normal,136,Y,0,Flat,1 912 | 41,M,ATA,120,157,0,Normal,182,N,0,Up,0 913 | 59,M,ASY,164,176,1,LVH,90,N,1,Flat,1 914 | 57,F,ASY,140,241,0,Normal,123,Y,0.2,Flat,1 915 | 45,M,TA,110,264,0,Normal,132,N,1.2,Flat,1 916 | 68,M,ASY,144,193,1,Normal,141,N,3.4,Flat,1 917 | 57,M,ASY,130,131,0,Normal,115,Y,1.2,Flat,1 918 | 57,F,ATA,130,236,0,LVH,174,N,0,Flat,1 919 | 38,M,NAP,138,175,0,Normal,173,N,0,Up,0 920 | -------------------------------------------------------------------------------- /Lesson0Julia.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "

\n", 8 | "\"GWU\n", 9 | "

" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "# 0 | A BRIEF INTRODUCTION TO JULIA" 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "metadata": {}, 22 | "source": [ 23 | "

This notebook by Dr JH Klopper is licensed under Attribution-NonCommercial-NoDerivatives 4.0 International

" 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "## Motivation for this notebook" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "metadata": {}, 36 | "source": [ 37 | "> This notebook introduces the Julia language and its basic syntax. It is intended for those who are new to Julia and would like to get a feel for the language. The analysis in this course are perfomed using the Julia language and the plots are similarly created using the Julia language. The course does not require students to learn or use any computer language. Instead, students are are allowed to use calculators or software such as Microsoft Excel to complete their calculations. However, for those who are interested, this notebook provides a brief introduction to Julia." 38 | ] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "metadata": {}, 43 | "source": [ 44 | "## The Julia Programming Language" 45 | ] 46 | }, 47 | { 48 | "cell_type": "markdown", 49 | "metadata": {}, 50 | "source": [ 51 | "This notebook serves as an introduction to coding in the Julia programming language. Julia is a high-level, high-performance, dynamic programming language. While it is a general-purpose language and can be used to write any application, it is particularly well-suited for scientific computing." 52 | ] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "metadata": {}, 57 | "source": [ 58 | "Julia was designed from the beginning for high performance. Julia programs compile to efficient native code for multiple platforms, wheter that be Windows, MacOS, or Linux or Intel/AMD or ARM-based processors. Julia is dynamically-typed, feels like a scripting language, and has good support for interactive use." 59 | ] 60 | }, 61 | { 62 | "cell_type": "markdown", 63 | "metadata": {}, 64 | "source": [ 65 | "This notebook is a part of a series of notebooks that make up an introduction to biostatistics. The intent of the course is to learn biostatistics and not the programming language. Any course on biostatistics requires calculations and the use of a programming language is a good way to do this. Julia is a great choice for this purpose. Readers who are interested are encouraged to learn Julia." 66 | ] 67 | }, 68 | { 69 | "cell_type": "markdown", 70 | "metadata": {}, 71 | "source": [ 72 | "The Julia code in all of the notebooks are preceeded by pseudo-code. Pseudo-code is written in plain English and describes what the code is doing. In this way a reader can follow along with the results and can completely ignore the code if they wish. This might be a shame as much of the data that we will be working with is generated by code. We take control of how the data is generated and this is a good way to learn about the data." 73 | ] 74 | }, 75 | { 76 | "cell_type": "markdown", 77 | "metadata": {}, 78 | "source": [ 79 | "For those then that want to explore the language and perhaps gain more from the course, please work through this notebook." 80 | ] 81 | }, 82 | { 83 | "cell_type": "markdown", 84 | "metadata": {}, 85 | "source": [ 86 | "## Simple arithmetic operations" 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "metadata": {}, 92 | "source": [ 93 | "Granted, your phone calculator can do a lot of calculations, and, I suppose, so can a spreadsheet. Calculators and spreadsheets, however, pale in comparison to doing mathematics using a computer language. First, though, baby-steps. Arithmetic." 94 | ] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "metadata": {}, 99 | "source": [ 100 | "### Doing addition and subtraction with Julia" 101 | ] 102 | }, 103 | { 104 | "cell_type": "markdown", 105 | "metadata": {}, 106 | "source": [ 107 | "Why count on your fingers when you can use a computer? Here's how you can add and subtract numbers in Julia. What about $1+1$? We calculate this simple sum in the code cell below. Note the pseudo-code in the first line. It can be identified by the `#` symbol. A `#` symbol in Julia is used to denote a comment. Comments are ignored by the Julia interpreter and are used to provide information to the reader. Our intention is clearly to add $1$ and $1$. The code comment (pseudo-code) is followed by and actual line of code, `1 + 1`. The result follows directly." 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": 1, 113 | "metadata": {}, 114 | "outputs": [ 115 | { 116 | "data": { 117 | "text/plain": [ 118 | "2" 119 | ] 120 | }, 121 | "metadata": {}, 122 | "output_type": "display_data" 123 | } 124 | ], 125 | "source": [ 126 | "# Add 1 and 1\n", 127 | "1 + 1" 128 | ] 129 | }, 130 | { 131 | "cell_type": "markdown", 132 | "metadata": {}, 133 | "source": [ 134 | "Wow, who would have belived that? $1+1=2$. It look's just like your textbook too, right? We have the digits $1$ and the $+$ operator. In fact, we can add many numbers. What about $1+2+3+4+5$?" 135 | ] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "execution_count": 2, 140 | "metadata": {}, 141 | "outputs": [ 142 | { 143 | "data": { 144 | "text/plain": [ 145 | "15" 146 | ] 147 | }, 148 | "metadata": {}, 149 | "output_type": "display_data" 150 | } 151 | ], 152 | "source": [ 153 | "# Add 1, 2, 3, 4, 5\n", 154 | "1 + 2 + 3 + 4 + 5" 155 | ] 156 | }, 157 | { 158 | "cell_type": "markdown", 159 | "metadata": {}, 160 | "source": [ 161 | "Okay, you could do that one with your fingers. What about $85454543+76554654342567$?" 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": 3, 167 | "metadata": {}, 168 | "outputs": [ 169 | { 170 | "data": { 171 | "text/plain": [ 172 | "76554739797110" 173 | ] 174 | }, 175 | "metadata": {}, 176 | "output_type": "display_data" 177 | } 178 | ], 179 | "source": [ 180 | "# Add 85454543 and 76554654342567\n", 181 | "85454543 + 76554654342567" 182 | ] 183 | }, 184 | { 185 | "cell_type": "markdown", 186 | "metadata": {}, 187 | "source": [ 188 | "No problem! What bout subtraction? Let's do $5345763456.34756 - 34563.4576345634$." 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": 4, 194 | "metadata": {}, 195 | "outputs": [ 196 | { 197 | "data": { 198 | "text/plain": [ 199 | "5.345728892889925e9" 200 | ] 201 | }, 202 | "metadata": {}, 203 | "output_type": "display_data" 204 | } 205 | ], 206 | "source": [ 207 | "# Do the subtract 5345763456.34756 - 34563.4576345634\n", 208 | "5345763456.34756 - 34563.4576345634" 209 | ] 210 | }, 211 | { 212 | "cell_type": "markdown", 213 | "metadata": {}, 214 | "source": [ 215 | "Julia returns the solution in scientific notation $5.345728892889925 \\times 10^9$. We could get standard notation, but that takes a bit of work and knowledge about Julia packages. The code is shown below, just in case you're curious. The `using` keyword is used to load a package. Packages are designed by Julia programmers and they greatly expand the capabilities of the language. The `Printf` package is used to format the output. The `@printf` macro is used to format the output. The `%.10f` is used to specify the number of decimal places. In our case, we choose $10$ decimal places." 216 | ] 217 | }, 218 | { 219 | "cell_type": "code", 220 | "execution_count": 5, 221 | "metadata": {}, 222 | "outputs": [ 223 | { 224 | "name": "stdout", 225 | "output_type": "stream", 226 | "text": [ 227 | "5345728892.8899250031" 228 | ] 229 | } 230 | ], 231 | "source": [ 232 | "# Print the last result in standard form, not scietific notation\n", 233 | "using Printf\n", 234 | "@printf(\"%.10f\", 5345763456.34756 - 34563.4576345634)" 235 | ] 236 | }, 237 | { 238 | "cell_type": "markdown", 239 | "metadata": {}, 240 | "source": [ 241 | "### Doing multiplication and division with Julia" 242 | ] 243 | }, 244 | { 245 | "cell_type": "markdown", 246 | "metadata": {}, 247 | "source": [ 248 | "Multiplication is easy. We use the `*` symbols. That is SHIFT+8 on most keyboards. So, what about $3 \\times 4$?" 249 | ] 250 | }, 251 | { 252 | "cell_type": "code", 253 | "execution_count": 6, 254 | "metadata": {}, 255 | "outputs": [ 256 | { 257 | "data": { 258 | "text/plain": [ 259 | "12" 260 | ] 261 | }, 262 | "metadata": {}, 263 | "output_type": "display_data" 264 | } 265 | ], 266 | "source": [ 267 | "# Multiply 3 and 4\n", 268 | "3 * 4" 269 | ] 270 | }, 271 | { 272 | "cell_type": "markdown", 273 | "metadata": {}, 274 | "source": [ 275 | "What is $3 \\div 4$? Well, keyboards do not have a division key $\\div$. Instead Julia uses the forward slash `/` for division." 276 | ] 277 | }, 278 | { 279 | "cell_type": "code", 280 | "execution_count": 7, 281 | "metadata": {}, 282 | "outputs": [ 283 | { 284 | "data": { 285 | "text/plain": [ 286 | "0.75" 287 | ] 288 | }, 289 | "metadata": {}, 290 | "output_type": "display_data" 291 | } 292 | ], 293 | "source": [ 294 | "# calculate 3 / 4\n", 295 | "3 / 4" 296 | ] 297 | }, 298 | { 299 | "cell_type": "markdown", 300 | "metadata": {}, 301 | "source": [ 302 | "Julia returns the decimal representation of the division." 303 | ] 304 | }, 305 | { 306 | "cell_type": "markdown", 307 | "metadata": {}, 308 | "source": [ 309 | "### Powers and roots in Julia" 310 | ] 311 | }, 312 | { 313 | "cell_type": "markdown", 314 | "metadata": {}, 315 | "source": [ 316 | "So then, what about $3 \\times 3 \\times 3 \\times 3 \\times 3$? That is $3^{5}$. Again, keyboards do not support superscripts as powers. Instead, Julia uses the `^` symbol. So, $3^5$ is calculated as follows." 317 | ] 318 | }, 319 | { 320 | "cell_type": "code", 321 | "execution_count": 8, 322 | "metadata": {}, 323 | "outputs": [ 324 | { 325 | "data": { 326 | "text/plain": [ 327 | "243" 328 | ] 329 | }, 330 | "metadata": {}, 331 | "output_type": "display_data" 332 | } 333 | ], 334 | "source": [ 335 | "# calculate 3^5\n", 336 | "3 ^ 5" 337 | ] 338 | }, 339 | { 340 | "cell_type": "markdown", 341 | "metadata": {}, 342 | "source": [ 343 | "What about the square root of $9$ or $\\sqrt{9}$? To do this, we need the `sqrt` function. Functions in Julia are keywords (reserved by the language). Functions are predesigned to perform tasks with the information you provide it. This information is called an argument (or arguments, pleural). Arguments are passed inside the parentesis `()` that follow directly after the function name (no spaces). So, the `sqrt` function takes one argument, the number you want to find the square root of. Here is how we do it." 344 | ] 345 | }, 346 | { 347 | "cell_type": "code", 348 | "execution_count": 9, 349 | "metadata": {}, 350 | "outputs": [ 351 | { 352 | "data": { 353 | "text/plain": [ 354 | "3.0" 355 | ] 356 | }, 357 | "metadata": {}, 358 | "output_type": "display_data" 359 | } 360 | ], 361 | "source": [ 362 | "# Calculate the square roots of 9\n", 363 | "sqrt(9)" 364 | ] 365 | }, 366 | { 367 | "cell_type": "markdown", 368 | "metadata": {}, 369 | "source": [ 370 | "We all know this is only one half of the answer. The square root of $9$ is $\\pm 3$, but Julia won't tell you that. Julia knows that your are smart. Okay then, what about the cube root of $27$ or $\\sqrt[3]{27}$? You guessed it. We use another function. It is `cbrt`." 371 | ] 372 | }, 373 | { 374 | "cell_type": "code", 375 | "execution_count": 10, 376 | "metadata": {}, 377 | "outputs": [ 378 | { 379 | "data": { 380 | "text/plain": [ 381 | "3.0" 382 | ] 383 | }, 384 | "metadata": {}, 385 | "output_type": "display_data" 386 | } 387 | ], 388 | "source": [ 389 | "# Calculate the cube root of 27\n", 390 | "cbrt(27)" 391 | ] 392 | }, 393 | { 394 | "cell_type": "markdown", 395 | "metadata": {}, 396 | "source": [ 397 | "Higher roots are recognized by the mathematical notation in (1)." 398 | ] 399 | }, 400 | { 401 | "cell_type": "markdown", 402 | "metadata": {}, 403 | "source": [ 404 | "$$\n", 405 | "\\sqrt[a]{b} = b^{1/a} \\tag{1}\n", 406 | "$$" 407 | ] 408 | }, 409 | { 410 | "cell_type": "markdown", 411 | "metadata": {}, 412 | "source": [ 413 | "Below, we calculate the fourth root of $16$ or $\\sqrt[4]{16}$." 414 | ] 415 | }, 416 | { 417 | "cell_type": "code", 418 | "execution_count": 11, 419 | "metadata": {}, 420 | "outputs": [ 421 | { 422 | "data": { 423 | "text/plain": [ 424 | "2.0" 425 | ] 426 | }, 427 | "metadata": {}, 428 | "output_type": "display_data" 429 | } 430 | ], 431 | "source": [ 432 | "# Calculate the fourth root of 16\n", 433 | "16^(1/4)" 434 | ] 435 | }, 436 | { 437 | "cell_type": "markdown", 438 | "metadata": {}, 439 | "source": [ 440 | "Note again that $-2$ would aldo to the trick. But we knew that already, right?" 441 | ] 442 | }, 443 | { 444 | "cell_type": "markdown", 445 | "metadata": {}, 446 | "source": [ 447 | "By the way, Julia can deal with complex numbers using the imaginary unit $i$ such that $i^{2}=-1$. The Julia keyword for the imaginary unit is `im`." 448 | ] 449 | }, 450 | { 451 | "cell_type": "code", 452 | "execution_count": 12, 453 | "metadata": {}, 454 | "outputs": [ 455 | { 456 | "data": { 457 | "text/plain": [ 458 | "0 + 1im" 459 | ] 460 | }, 461 | "metadata": {}, 462 | "output_type": "display_data" 463 | } 464 | ], 465 | "source": [ 466 | "# Print the imaginary unit\n", 467 | "1im" 468 | ] 469 | }, 470 | { 471 | "cell_type": "markdown", 472 | "metadata": {}, 473 | "source": [ 474 | "We see the solution `0 + 1im` which in mathematical notation is $0+1i$. This is a complex number with a real part $0$ and an imaginary part $1$. Both the real and the imginary parts of a complex number are real numbers. The imaginary part is multiplied by the imaginary unit $i$." 475 | ] 476 | }, 477 | { 478 | "cell_type": "markdown", 479 | "metadata": {}, 480 | "source": [ 481 | "Now for something really spectacular, $\\sqrt{-1}$. There is no real number that can be multiplied by itself to give $-1$. But, we can use the imaginary unit $i$. So, $\\sqrt{-1} = i$. So, $\\sqrt{-1}$ is written as `sqrt(-1 + 0im)`. The `0im` is there to make sure that Julia knows that the imaginary part is zero. Here is how we do it." 482 | ] 483 | }, 484 | { 485 | "cell_type": "code", 486 | "execution_count": 13, 487 | "metadata": {}, 488 | "outputs": [ 489 | { 490 | "data": { 491 | "text/plain": [ 492 | "0.0 + 1.0im" 493 | ] 494 | }, 495 | "metadata": {}, 496 | "output_type": "display_data" 497 | } 498 | ], 499 | "source": [ 500 | "# Calculate the square root of -1\n", 501 | "sqrt(-1 + 0im)" 502 | ] 503 | }, 504 | { 505 | "cell_type": "markdown", 506 | "metadata": {}, 507 | "source": [ 508 | "We can use the alternative notation below, where we use the `Complex` function to create a complex number $-1$, which is in fact $-1 + 0 i$. The `Complex` function takes two arguments, the real and imaginary parts of the complex number." 509 | ] 510 | }, 511 | { 512 | "cell_type": "code", 513 | "execution_count": 14, 514 | "metadata": {}, 515 | "outputs": [ 516 | { 517 | "data": { 518 | "text/plain": [ 519 | "0.0 + 1.0im" 520 | ] 521 | }, 522 | "metadata": {}, 523 | "output_type": "display_data" 524 | } 525 | ], 526 | "source": [ 527 | "# Calculate the square root of -1\n", 528 | "sqrt(complex(-1, 0))" 529 | ] 530 | }, 531 | { 532 | "cell_type": "markdown", 533 | "metadata": {}, 534 | "source": [ 535 | "### The order of arithmetic operations" 536 | ] 537 | }, 538 | { 539 | "cell_type": "markdown", 540 | "metadata": {}, 541 | "source": [ 542 | "Julia follows the familiar mathematical order of arithmetical operations. This is the order in which operations are performed. The order is shown in (2)." 543 | ] 544 | }, 545 | { 546 | "cell_type": "markdown", 547 | "metadata": {}, 548 | "source": [ 549 | "$$\n", 550 | "\\begin{align*}\n", 551 | "&\\text{1. Parentheses} \\\\\n", 552 | "&\\text{2. Exponents} \\\\\n", 553 | "&\\text{3. Multiplication and division} \\\\\n", 554 | "&\\text{4. Addition and subtraction}\n", 555 | "\\end{align*}\n", 556 | "\\tag{2}\n", 557 | "$$" 558 | ] 559 | }, 560 | { 561 | "cell_type": "markdown", 562 | "metadata": {}, 563 | "source": [ 564 | "Never, ever sweat this, though. Also, don't watch YouTube videos that try to confuse. USE PARENTHESES! They are our friends. In the code cell below, we calculate the expression in (3)." 565 | ] 566 | }, 567 | { 568 | "cell_type": "markdown", 569 | "metadata": {}, 570 | "source": [ 571 | "$$\\left( \\left( 3 + 4 \\right) \\times 7 \\right) - 3^{2} \\tag{3}$$" 572 | ] 573 | }, 574 | { 575 | "cell_type": "code", 576 | "execution_count": 15, 577 | "metadata": {}, 578 | "outputs": [ 579 | { 580 | "data": { 581 | "text/plain": [ 582 | "40" 583 | ] 584 | }, 585 | "metadata": {}, 586 | "output_type": "display_data" 587 | } 588 | ], 589 | "source": [ 590 | "# Calculate ((3+4) * 7) - 3^2\n", 591 | "((3 + 4) * 7) - 3^2" 592 | ] 593 | }, 594 | { 595 | "cell_type": "markdown", 596 | "metadata": {}, 597 | "source": [ 598 | "### Logarithms and exponents" 599 | ] 600 | }, 601 | { 602 | "cell_type": "markdown", 603 | "metadata": {}, 604 | "source": [ 605 | "We define logarithms in (4)." 606 | ] 607 | }, 608 | { 609 | "cell_type": "markdown", 610 | "metadata": {}, 611 | "source": [ 612 | "$$\n", 613 | "\\begin{align*}\n", 614 | "\\log_{a} b &= c \\text{ means that } a^{c} = b \\tag{4}\n", 615 | "\\end{align*}\n", 616 | "$$" 617 | ] 618 | }, 619 | { 620 | "cell_type": "markdown", 621 | "metadata": {}, 622 | "source": [ 623 | "We define the natural logarithm when $a$ in (4) is Euler's number $e$. Euler's number is a mathematical constant that is approximately equal to $2.71828$. The natural logarithm is denoted by $\\ln$. Let's start, though, by calculating $\\log_{10} 1000$. This should clearly be $3$ since $10^{3}=1000$. We use the `log10` function in Julia." 624 | ] 625 | }, 626 | { 627 | "cell_type": "code", 628 | "execution_count": 16, 629 | "metadata": {}, 630 | "outputs": [ 631 | { 632 | "data": { 633 | "text/plain": [ 634 | "3.0" 635 | ] 636 | }, 637 | "metadata": {}, 638 | "output_type": "display_data" 639 | } 640 | ], 641 | "source": [ 642 | "# Calculate the log base 10 of 1000\n", 643 | "log10(1000)" 644 | ] 645 | }, 646 | { 647 | "cell_type": "markdown", 648 | "metadata": {}, 649 | "source": [ 650 | "To use the mathematical constant $e$ (Euler’s number) in Julia, we type `\\euler` and hit the TAB key." 651 | ] 652 | }, 653 | { 654 | "cell_type": "code", 655 | "execution_count": 17, 656 | "metadata": {}, 657 | "outputs": [ 658 | { 659 | "data": { 660 | "text/plain": [ 661 | "ℯ = 2.7182818284590..." 662 | ] 663 | }, 664 | "metadata": {}, 665 | "output_type": "display_data" 666 | } 667 | ], 668 | "source": [ 669 | "# Print the irrational number e (Euler's number)\n", 670 | "ℯ" 671 | ] 672 | }, 673 | { 674 | "cell_type": "markdown", 675 | "metadata": {}, 676 | "source": [ 677 | "By the way, we can do the same with $\\pi$ by typing `\\pi` and hitting the TAB key." 678 | ] 679 | }, 680 | { 681 | "cell_type": "code", 682 | "execution_count": 18, 683 | "metadata": {}, 684 | "outputs": [ 685 | { 686 | "data": { 687 | "text/plain": [ 688 | "π = 3.1415926535897..." 689 | ] 690 | }, 691 | "metadata": {}, 692 | "output_type": "display_data" 693 | } 694 | ], 695 | "source": [ 696 | "# Show the value of pi\n", 697 | "π" 698 | ] 699 | }, 700 | { 701 | "cell_type": "markdown", 702 | "metadata": {}, 703 | "source": [ 704 | "Back to logarithms. Let's calculate $\\log_{e} 1000$. This should be approximately $6.907755$ since $e^{6.907755} \\approx 1000$. We use the `log` function in Julia." 705 | ] 706 | }, 707 | { 708 | "cell_type": "code", 709 | "execution_count": 19, 710 | "metadata": {}, 711 | "outputs": [ 712 | { 713 | "data": { 714 | "text/plain": [ 715 | "6.907755278982137" 716 | ] 717 | }, 718 | "metadata": {}, 719 | "output_type": "display_data" 720 | } 721 | ], 722 | "source": [ 723 | "# calculate the natural logarithm of 1000\n", 724 | "log(1000)" 725 | ] 726 | }, 727 | { 728 | "cell_type": "markdown", 729 | "metadata": {}, 730 | "source": [ 731 | "To calculate the exponential function $e^{x}$, we use the `exp` function in Julia. Let's calculate $e^{3}$." 732 | ] 733 | }, 734 | { 735 | "cell_type": "code", 736 | "execution_count": 20, 737 | "metadata": {}, 738 | "outputs": [ 739 | { 740 | "data": { 741 | "text/plain": [ 742 | "20.085536923187668" 743 | ] 744 | }, 745 | "metadata": {}, 746 | "output_type": "display_data" 747 | } 748 | ], 749 | "source": [ 750 | "# calculate the exponential of 3\n", 751 | "exp(3)" 752 | ] 753 | }, 754 | { 755 | "cell_type": "markdown", 756 | "metadata": {}, 757 | "source": [ 758 | "To be sure, $e^{1}=e$, so we can use use `exp(1)` to get the value of Euler's number $e$." 759 | ] 760 | }, 761 | { 762 | "cell_type": "code", 763 | "execution_count": 21, 764 | "metadata": {}, 765 | "outputs": [ 766 | { 767 | "data": { 768 | "text/plain": [ 769 | "2.718281828459045" 770 | ] 771 | }, 772 | "metadata": {}, 773 | "output_type": "display_data" 774 | } 775 | ], 776 | "source": [ 777 | "# Use exp(1) to calculate e\n", 778 | "exp(1)" 779 | ] 780 | }, 781 | { 782 | "cell_type": "markdown", 783 | "metadata": {}, 784 | "source": [ 785 | "### Trigonometric functions" 786 | ] 787 | }, 788 | { 789 | "cell_type": "markdown", 790 | "metadata": {}, 791 | "source": [ 792 | "Yes, they are all here and accounted for. The trigonometric functions take their arguments in radians. We see one example of each of the six trigonometric functions below." 793 | ] 794 | }, 795 | { 796 | "cell_type": "code", 797 | "execution_count": 22, 798 | "metadata": {}, 799 | "outputs": [ 800 | { 801 | "data": { 802 | "text/plain": [ 803 | "0.0" 804 | ] 805 | }, 806 | "metadata": {}, 807 | "output_type": "display_data" 808 | } 809 | ], 810 | "source": [ 811 | "# Calculate the sine of π\n", 812 | "sin(π)" 813 | ] 814 | }, 815 | { 816 | "cell_type": "code", 817 | "execution_count": 23, 818 | "metadata": {}, 819 | "outputs": [ 820 | { 821 | "data": { 822 | "text/plain": [ 823 | "-1.0" 824 | ] 825 | }, 826 | "metadata": {}, 827 | "output_type": "display_data" 828 | } 829 | ], 830 | "source": [ 831 | "# Calculate the cosine of π\n", 832 | "cos(π)" 833 | ] 834 | }, 835 | { 836 | "cell_type": "markdown", 837 | "metadata": {}, 838 | "source": [ 839 | "The trigonometric functions $\\tan{\\left( \\frac{\\pi}{4} \\right)}$ returns an interesting result." 840 | ] 841 | }, 842 | { 843 | "cell_type": "code", 844 | "execution_count": 24, 845 | "metadata": {}, 846 | "outputs": [ 847 | { 848 | "data": { 849 | "text/plain": [ 850 | "0.9999999999999999" 851 | ] 852 | }, 853 | "metadata": {}, 854 | "output_type": "display_data" 855 | } 856 | ], 857 | "source": [ 858 | "# Calculate the tangent of π/4\n", 859 | "tan(π/4)" 860 | ] 861 | }, 862 | { 863 | "cell_type": "markdown", 864 | "metadata": {}, 865 | "source": [ 866 | "We see results such as $0.9999999999999999$ often when using a computer language on a machine that has finite precision. The execution of the code is done in a finite number of steps. The computer has a finite number of bits to store numbers in. This means that the computer can only store a finite number of digits. The results is that the computer can only store an approximation of the number. This is why we see the result of $\\tan{\\left( \\frac{\\pi}{4} \\right)}$ as $0.9999999999999999$ and not $1$." 867 | ] 868 | }, 869 | { 870 | "cell_type": "code", 871 | "execution_count": 25, 872 | "metadata": {}, 873 | "outputs": [ 874 | { 875 | "data": { 876 | "text/plain": [ 877 | "2.0000000000000004" 878 | ] 879 | }, 880 | "metadata": {}, 881 | "output_type": "display_data" 882 | } 883 | ], 884 | "source": [ 885 | "# Calculate the cosecant of π/6\n", 886 | "csc(π/6)" 887 | ] 888 | }, 889 | { 890 | "cell_type": "markdown", 891 | "metadata": {}, 892 | "source": [ 893 | "We see a similar _problem_ as before. Clearly the result is $2$ and we won't belabor the point." 894 | ] 895 | }, 896 | { 897 | "cell_type": "code", 898 | "execution_count": 26, 899 | "metadata": {}, 900 | "outputs": [ 901 | { 902 | "data": { 903 | "text/plain": [ 904 | "1.9999999999999996" 905 | ] 906 | }, 907 | "metadata": {}, 908 | "output_type": "display_data" 909 | } 910 | ], 911 | "source": [ 912 | "# Calculate the secant of π/3\n", 913 | "sec(π/3)" 914 | ] 915 | }, 916 | { 917 | "cell_type": "code", 918 | "execution_count": 27, 919 | "metadata": {}, 920 | "outputs": [ 921 | { 922 | "data": { 923 | "text/plain": [ 924 | "6.123233995736766e-17" 925 | ] 926 | }, 927 | "metadata": {}, 928 | "output_type": "display_data" 929 | } 930 | ], 931 | "source": [ 932 | "# Calculate the cotangent of π/2\n", 933 | "cot(π/2)" 934 | ] 935 | }, 936 | { 937 | "cell_type": "markdown", 938 | "metadata": {}, 939 | "source": [ 940 | "Okay, we will belabor it one more time. The solution as printed above is $0.00000000000000006123233995736766$. It is, as before, the result of the computer's finite precision. The computer it trying to tell you that the answer is $0$." 941 | ] 942 | }, 943 | { 944 | "cell_type": "markdown", 945 | "metadata": {}, 946 | "source": [ 947 | "All the inverse functions are available in Julia too. They are `asin`, `acos`, and `atan`. We also have the hyperbolic functions `sinh`, `cosh`, and `tanh`. Absolutely go and try them out. We see $\\arcsin{\\left( 1 \\right)}$ below." 948 | ] 949 | }, 950 | { 951 | "cell_type": "code", 952 | "execution_count": 28, 953 | "metadata": {}, 954 | "outputs": [ 955 | { 956 | "data": { 957 | "text/plain": [ 958 | "1.5707963267948966" 959 | ] 960 | }, 961 | "metadata": {}, 962 | "output_type": "display_data" 963 | } 964 | ], 965 | "source": [ 966 | "# Calculate the inverse sine of 1\n", 967 | "asin(1)" 968 | ] 969 | }, 970 | { 971 | "cell_type": "markdown", 972 | "metadata": {}, 973 | "source": [ 974 | "### Conditional operators" 975 | ] 976 | }, 977 | { 978 | "cell_type": "markdown", 979 | "metadata": {}, 980 | "source": [ 981 | "It is common in mathematics to wonder which fraction is larger, or which number is larger, or smaller. We can use the conditional operators to compare numbers. Before looking at common conditional operators, let's look at Boolean values. Boolean values are either `true` or `false`." 982 | ] 983 | }, 984 | { 985 | "cell_type": "code", 986 | "execution_count": 29, 987 | "metadata": {}, 988 | "outputs": [ 989 | { 990 | "data": { 991 | "text/plain": [ 992 | "true" 993 | ] 994 | }, 995 | "metadata": {}, 996 | "output_type": "display_data" 997 | } 998 | ], 999 | "source": [ 1000 | "# true\n", 1001 | "true" 1002 | ] 1003 | }, 1004 | { 1005 | "cell_type": "code", 1006 | "execution_count": 30, 1007 | "metadata": {}, 1008 | "outputs": [ 1009 | { 1010 | "data": { 1011 | "text/plain": [ 1012 | "false" 1013 | ] 1014 | }, 1015 | "metadata": {}, 1016 | "output_type": "display_data" 1017 | } 1018 | ], 1019 | "source": [ 1020 | "# false\n", 1021 | "false" 1022 | ] 1023 | }, 1024 | { 1025 | "cell_type": "markdown", 1026 | "metadata": {}, 1027 | "source": [ 1028 | "The `true` keyword represents the Boolean value _true_, while the `false` keyword represents the boolean value _false_. Internally, a computer represents `true` as $1$ and `false` as $0$. We can do arithmetic with Boolean values. Let's see what happens when we add `true` and `false`." 1029 | ] 1030 | }, 1031 | { 1032 | "cell_type": "code", 1033 | "execution_count": 31, 1034 | "metadata": {}, 1035 | "outputs": [ 1036 | { 1037 | "data": { 1038 | "text/plain": [ 1039 | "1" 1040 | ] 1041 | }, 1042 | "metadata": {}, 1043 | "output_type": "display_data" 1044 | } 1045 | ], 1046 | "source": [ 1047 | "# Add true and false\n", 1048 | "true + false" 1049 | ] 1050 | }, 1051 | { 1052 | "cell_type": "markdown", 1053 | "metadata": {}, 1054 | "source": [ 1055 | "We get $1$ as expected because $1+0=1$. Now for the commonly used conditional operators. We consider the operators in the table below. When used properly, they return a Boolean value." 1056 | ] 1057 | }, 1058 | { 1059 | "cell_type": "markdown", 1060 | "metadata": {}, 1061 | "source": [ 1062 | "| Operator | Description |\n", 1063 | "|----------|-------------|\n", 1064 | "| `==` | Equal to (value only) |\n", 1065 | "| `===` | Identical to (value and type) |\n", 1066 | "| `!=` | Not equal to |\n", 1067 | "| `>` | Greater than |\n", 1068 | "| `<` | Less than |\n", 1069 | "| `>=` | Greater than or equal to |\n", 1070 | "| `<=` | Less than or equal to |" 1071 | ] 1072 | }, 1073 | { 1074 | "cell_type": "markdown", 1075 | "metadata": {}, 1076 | "source": [ 1077 | "Let's see some in use." 1078 | ] 1079 | }, 1080 | { 1081 | "cell_type": "code", 1082 | "execution_count": 32, 1083 | "metadata": {}, 1084 | "outputs": [ 1085 | { 1086 | "data": { 1087 | "text/plain": [ 1088 | "true" 1089 | ] 1090 | }, 1091 | "metadata": {}, 1092 | "output_type": "display_data" 1093 | } 1094 | ], 1095 | "source": [ 1096 | "# Is 3 equal to 3?\n", 1097 | "3 == 3" 1098 | ] 1099 | }, 1100 | { 1101 | "cell_type": "code", 1102 | "execution_count": 33, 1103 | "metadata": {}, 1104 | "outputs": [ 1105 | { 1106 | "data": { 1107 | "text/plain": [ 1108 | "false" 1109 | ] 1110 | }, 1111 | "metadata": {}, 1112 | "output_type": "display_data" 1113 | } 1114 | ], 1115 | "source": [ 1116 | "# Is 3 not equal to 3.0?\n", 1117 | "3 != 3.0" 1118 | ] 1119 | }, 1120 | { 1121 | "cell_type": "markdown", 1122 | "metadata": {}, 1123 | "source": [ 1124 | "We learnt an important lesson with the last example. The integer $3$ is equal to the floating point number (number with a decimal place) $3.0$. If we want to determine if $3$ is equal to $3.0$ in value and type (more on types later), we use the `===` operator (which means _identical to_). Let's see this in action." 1125 | ] 1126 | }, 1127 | { 1128 | "cell_type": "code", 1129 | "execution_count": 34, 1130 | "metadata": {}, 1131 | "outputs": [ 1132 | { 1133 | "data": { 1134 | "text/plain": [ 1135 | "false" 1136 | ] 1137 | }, 1138 | "metadata": {}, 1139 | "output_type": "display_data" 1140 | } 1141 | ], 1142 | "source": [ 1143 | "# Is 3 identical to 3.0?\n", 1144 | "3 === 3.0" 1145 | ] 1146 | }, 1147 | { 1148 | "cell_type": "markdown", 1149 | "metadata": {}, 1150 | "source": [ 1151 | "Now we see a `false`. Below are some more examples of using conditional operators." 1152 | ] 1153 | }, 1154 | { 1155 | "cell_type": "code", 1156 | "execution_count": 35, 1157 | "metadata": {}, 1158 | "outputs": [ 1159 | { 1160 | "data": { 1161 | "text/plain": [ 1162 | "true" 1163 | ] 1164 | }, 1165 | "metadata": {}, 1166 | "output_type": "display_data" 1167 | } 1168 | ], 1169 | "source": [ 1170 | "# Is 3 greater than 2?\n", 1171 | "3 > 2" 1172 | ] 1173 | }, 1174 | { 1175 | "cell_type": "code", 1176 | "execution_count": 36, 1177 | "metadata": {}, 1178 | "outputs": [ 1179 | { 1180 | "data": { 1181 | "text/plain": [ 1182 | "false" 1183 | ] 1184 | }, 1185 | "metadata": {}, 1186 | "output_type": "display_data" 1187 | } 1188 | ], 1189 | "source": [ 1190 | "# Is 3 less than 2?\n", 1191 | "3 < 2" 1192 | ] 1193 | }, 1194 | { 1195 | "cell_type": "code", 1196 | "execution_count": 37, 1197 | "metadata": {}, 1198 | "outputs": [ 1199 | { 1200 | "data": { 1201 | "text/plain": [ 1202 | "true" 1203 | ] 1204 | }, 1205 | "metadata": {}, 1206 | "output_type": "display_data" 1207 | } 1208 | ], 1209 | "source": [ 1210 | "# Is 3 greater than or equal to 3?\n", 1211 | "3 >= 3" 1212 | ] 1213 | }, 1214 | { 1215 | "cell_type": "code", 1216 | "execution_count": 38, 1217 | "metadata": {}, 1218 | "outputs": [ 1219 | { 1220 | "data": { 1221 | "text/plain": [ 1222 | "true" 1223 | ] 1224 | }, 1225 | "metadata": {}, 1226 | "output_type": "display_data" 1227 | } 1228 | ], 1229 | "source": [ 1230 | "# Is 3 less than or equal to 3?\n", 1231 | "3 <= 3" 1232 | ] 1233 | }, 1234 | { 1235 | "cell_type": "markdown", 1236 | "metadata": {}, 1237 | "source": [ 1238 | "## Computer variables in Julia" 1239 | ] 1240 | }, 1241 | { 1242 | "cell_type": "markdown", 1243 | "metadata": {}, 1244 | "source": [ 1245 | "Computer variables are like the variables in mathematics. They are used to store values. The values can be numbers, text, or any other data type. In Julia, we can assign a value to a variable using the assignment operator `=`. The assignment operator is not the same as the equal operator `==`. The equal operator is used to compare two values as we explored in the previous section." 1246 | ] 1247 | }, 1248 | { 1249 | "cell_type": "markdown", 1250 | "metadata": {}, 1251 | "source": [ 1252 | "The assignment operator `=` assigns the value on the right-hand side to the variable on the left-hand side. Let's see this in action. We assign the value $3$ to the variable `a`." 1253 | ] 1254 | }, 1255 | { 1256 | "cell_type": "code", 1257 | "execution_count": 103, 1258 | "metadata": {}, 1259 | "outputs": [ 1260 | { 1261 | "data": { 1262 | "text/plain": [ 1263 | "3" 1264 | ] 1265 | }, 1266 | "metadata": {}, 1267 | "output_type": "display_data" 1268 | } 1269 | ], 1270 | "source": [ 1271 | "# Assign the value three to the variable a\n", 1272 | "a = 3" 1273 | ] 1274 | }, 1275 | { 1276 | "cell_type": "markdown", 1277 | "metadata": {}, 1278 | "source": [ 1279 | "We can now recall this value by simply referring to `a`." 1280 | ] 1281 | }, 1282 | { 1283 | "cell_type": "code", 1284 | "execution_count": 104, 1285 | "metadata": {}, 1286 | "outputs": [ 1287 | { 1288 | "data": { 1289 | "text/plain": [ 1290 | "3" 1291 | ] 1292 | }, 1293 | "metadata": {}, 1294 | "output_type": "display_data" 1295 | } 1296 | ], 1297 | "source": [ 1298 | "# Call the value of a\n", 1299 | "a" 1300 | ] 1301 | }, 1302 | { 1303 | "cell_type": "markdown", 1304 | "metadata": {}, 1305 | "source": [ 1306 | "A variable can be reassigned a new value. Let's assign the value $4$ to the variable `a`." 1307 | ] 1308 | }, 1309 | { 1310 | "cell_type": "code", 1311 | "execution_count": 105, 1312 | "metadata": {}, 1313 | "outputs": [ 1314 | { 1315 | "data": { 1316 | "text/plain": [ 1317 | "4" 1318 | ] 1319 | }, 1320 | "metadata": {}, 1321 | "output_type": "display_data" 1322 | } 1323 | ], 1324 | "source": [ 1325 | "# Reassign the value 4 to the variable a\n", 1326 | "a = 4" 1327 | ] 1328 | }, 1329 | { 1330 | "cell_type": "markdown", 1331 | "metadata": {}, 1332 | "source": [ 1333 | "When we call `a` now, we get the new value $4$." 1334 | ] 1335 | }, 1336 | { 1337 | "cell_type": "code", 1338 | "execution_count": 106, 1339 | "metadata": {}, 1340 | "outputs": [ 1341 | { 1342 | "data": { 1343 | "text/plain": [ 1344 | "4" 1345 | ] 1346 | }, 1347 | "metadata": {}, 1348 | "output_type": "display_data" 1349 | } 1350 | ], 1351 | "source": [ 1352 | "# Call the value of a\n", 1353 | "a" 1354 | ] 1355 | }, 1356 | { 1357 | "cell_type": "markdown", 1358 | "metadata": {}, 1359 | "source": [ 1360 | "Since the assigment operator assigns the right hand side to the left hand side, we use the current value to update the variable. Let's see this in action." 1361 | ] 1362 | }, 1363 | { 1364 | "cell_type": "code", 1365 | "execution_count": 107, 1366 | "metadata": {}, 1367 | "outputs": [ 1368 | { 1369 | "data": { 1370 | "text/plain": [ 1371 | "5" 1372 | ] 1373 | }, 1374 | "metadata": {}, 1375 | "output_type": "display_data" 1376 | } 1377 | ], 1378 | "source": [ 1379 | "# Add 1 to a and reassign the value to a\n", 1380 | "a = a + 1" 1381 | ] 1382 | }, 1383 | { 1384 | "cell_type": "markdown", 1385 | "metadata": {}, 1386 | "source": [ 1387 | "The previous line of code would not make sense in mathematics. When the line of code is executed the current value in `a` is $4$. The code adds $1$ to this to get $5$. The value $5$ is then assigned to `a`. The value $4$ is lost." 1388 | ] 1389 | }, 1390 | { 1391 | "cell_type": "markdown", 1392 | "metadata": {}, 1393 | "source": [ 1394 | "There is shorthand for this operation. We can use the `+=` operator. Let's see this in action." 1395 | ] 1396 | }, 1397 | { 1398 | "cell_type": "code", 1399 | "execution_count": 108, 1400 | "metadata": {}, 1401 | "outputs": [ 1402 | { 1403 | "data": { 1404 | "text/plain": [ 1405 | "6" 1406 | ] 1407 | }, 1408 | "metadata": {}, 1409 | "output_type": "display_data" 1410 | } 1411 | ], 1412 | "source": [ 1413 | "# Add 1 to a and reassign the value to a\n", 1414 | "a += 1" 1415 | ] 1416 | }, 1417 | { 1418 | "cell_type": "markdown", 1419 | "metadata": {}, 1420 | "source": [ 1421 | "The `+=` operator is a shorthand for the operation `a = a + 1`. If we call `a` now, we get the value $6$." 1422 | ] 1423 | }, 1424 | { 1425 | "cell_type": "code", 1426 | "execution_count": 109, 1427 | "metadata": {}, 1428 | "outputs": [ 1429 | { 1430 | "data": { 1431 | "text/plain": [ 1432 | "6" 1433 | ] 1434 | }, 1435 | "metadata": {}, 1436 | "output_type": "display_data" 1437 | } 1438 | ], 1439 | "source": [ 1440 | "# Call the value of a\n", 1441 | "a" 1442 | ] 1443 | }, 1444 | { 1445 | "cell_type": "markdown", 1446 | "metadata": {}, 1447 | "source": [ 1448 | "## Controlling the flow of execution of code in Julia" 1449 | ] 1450 | }, 1451 | { 1452 | "cell_type": "markdown", 1453 | "metadata": {}, 1454 | "source": [ 1455 | "### The `for` loop in Julia" 1456 | ] 1457 | }, 1458 | { 1459 | "cell_type": "markdown", 1460 | "metadata": {}, 1461 | "source": [ 1462 | "Enough of the basic arithmetic operations. Let’s move on to the fundamental concepts of programming. We start with the `for` loop. The `for` loop is used to repeat a block of code a number of times. In the code cell below, we use an iterator to loop over the values $1$ through $5$ (in steps of $1$) and print the value to the screen. The iterator is the variable `i`." 1463 | ] 1464 | }, 1465 | { 1466 | "cell_type": "code", 1467 | "execution_count": 39, 1468 | "metadata": {}, 1469 | "outputs": [ 1470 | { 1471 | "name": "stdout", 1472 | "output_type": "stream", 1473 | "text": [ 1474 | "1\n", 1475 | "2\n", 1476 | "3\n", 1477 | "4\n", 1478 | "5\n" 1479 | ] 1480 | } 1481 | ], 1482 | "source": [ 1483 | "# Use a for loop and loop over the integers 1, 2, 3, 4, 5 and print each number\n", 1484 | "for i in 1:5\n", 1485 | " println(i)\n", 1486 | "end" 1487 | ] 1488 | }, 1489 | { 1490 | "cell_type": "markdown", 1491 | "metadata": {}, 1492 | "source": [ 1493 | "The code should be self-evident based on the output. We just have to get used to the syntax. The `for` keyword is followed by the iterator variable `i`, the `in` keyword, and the range of values that the iterator will take. The block of code to be repeated (using the `println` function to print the current value of the variable `i` to the screen) is indented and follows the `for` statement. The block of code is ended by the `end` keyword." 1494 | ] 1495 | }, 1496 | { 1497 | "cell_type": "markdown", 1498 | "metadata": {}, 1499 | "source": [ 1500 | "In the code we make use of a range object, using the short-hand notation `1:5`. This is a range object that represents the values $1$ through $5$ (inclusive). The `for` loop will iterate over the values in the range object." 1501 | ] 1502 | }, 1503 | { 1504 | "cell_type": "code", 1505 | "execution_count": 40, 1506 | "metadata": {}, 1507 | "outputs": [ 1508 | { 1509 | "data": { 1510 | "text/plain": [ 1511 | "1:5" 1512 | ] 1513 | }, 1514 | "metadata": {}, 1515 | "output_type": "display_data" 1516 | } 1517 | ], 1518 | "source": [ 1519 | "# Create the range object 1:5\n", 1520 | "1:5" 1521 | ] 1522 | }, 1523 | { 1524 | "cell_type": "markdown", 1525 | "metadata": {}, 1526 | "source": [ 1527 | "If we pass a range object to the `collect` function, we can see all the values in the range object. The `collect` function will return an array (a Vector type) of all the values in the range object. We see this in the code cell below." 1528 | ] 1529 | }, 1530 | { 1531 | "cell_type": "code", 1532 | "execution_count": 41, 1533 | "metadata": {}, 1534 | "outputs": [ 1535 | { 1536 | "data": { 1537 | "text/plain": [ 1538 | "5-element Vector{Int64}:\n", 1539 | " 1\n", 1540 | " 2\n", 1541 | " 3\n", 1542 | " 4\n", 1543 | " 5" 1544 | ] 1545 | }, 1546 | "metadata": {}, 1547 | "output_type": "display_data" 1548 | } 1549 | ], 1550 | "source": [ 1551 | "# Use the collect function to create an array of the integers 1, 2, 3, 4, 5\n", 1552 | "collect(1:5)" 1553 | ] 1554 | }, 1555 | { 1556 | "cell_type": "markdown", 1557 | "metadata": {}, 1558 | "source": [ 1559 | "We actually see quite a bit of information here. We'll get into that a bit later! The fun never ends." 1560 | ] 1561 | }, 1562 | { 1563 | "cell_type": "markdown", 1564 | "metadata": {}, 1565 | "source": [ 1566 | "Loops such as the `for` loop can be nested. This means that one loop can be placed inside another loop. The inner loop will be executed for each iteration of the outer loop. We see an example of a nested `for` loop below. The outer loop iterates over the values $1$ through $3$ and the inner loop iterates over the values $1$ through $2$. The inner loop is indented to show that it is inside the outer loop. In the body of the inner loop we print a `tuple` of the values of the iterator variables `i` and `j`. More about `tuples` later. Yay!" 1567 | ] 1568 | }, 1569 | { 1570 | "cell_type": "code", 1571 | "execution_count": 42, 1572 | "metadata": {}, 1573 | "outputs": [ 1574 | { 1575 | "name": "stdout", 1576 | "output_type": "stream", 1577 | "text": [ 1578 | "(1, 1)\n", 1579 | "(1, 2)\n", 1580 | "(2, 1)\n", 1581 | "(2, 2)\n", 1582 | "(3, 1)\n", 1583 | "(3, 2)\n" 1584 | ] 1585 | } 1586 | ], 1587 | "source": [ 1588 | "# Create a nested for loop\n", 1589 | "# Let the outer loop iterate over the integers 1, 2, 3\n", 1590 | "# Let the inner loop iterate over the integers 1, 2\n", 1591 | "# Print both values to the screen during each loop\n", 1592 | "\n", 1593 | "for i in 1:3\n", 1594 | " for j in 1:2\n", 1595 | " println((i, j))\n", 1596 | " end\n", 1597 | "end" 1598 | ] 1599 | }, 1600 | { 1601 | "cell_type": "markdown", 1602 | "metadata": {}, 1603 | "source": [ 1604 | "Note how the inner loop is executed for each iteration of the outer loop. The inner loop is executed twice for each iteration of the outer loop. The inner loop is executed a total of $6$ times." 1605 | ] 1606 | }, 1607 | { 1608 | "cell_type": "markdown", 1609 | "metadata": {}, 1610 | "source": [ 1611 | "### The `while` loop in Julia" 1612 | ] 1613 | }, 1614 | { 1615 | "cell_type": "markdown", 1616 | "metadata": {}, 1617 | "source": [ 1618 | "The other type of loop is the `while` loop. The `while` loop is used to repeat a block of code while a condition is `true`. The `while` loop is shown in the code cell below. The `while` keyword is followed by a condition that is evaluated. The block of code to be repeated is indented and follows the `while` statement. The block of code is ended by the `end` keyword." 1619 | ] 1620 | }, 1621 | { 1622 | "cell_type": "markdown", 1623 | "metadata": {}, 1624 | "source": [ 1625 | "In the code cell below we assign a value to a computer variable `i` and then we enter a `while` loop. The condition `i < 5` is evaluated. If the condition is `true`, the block of code is executed. The block of code increments the value of the variable `i` by $1$. The condition is then evaluated again. This process is repeated until the condition is `false`. We'll print the value of the variable `i` to the screen." 1626 | ] 1627 | }, 1628 | { 1629 | "cell_type": "code", 1630 | "execution_count": 43, 1631 | "metadata": {}, 1632 | "outputs": [ 1633 | { 1634 | "name": "stdout", 1635 | "output_type": "stream", 1636 | "text": [ 1637 | "1\n", 1638 | "2\n", 1639 | "3\n", 1640 | "4\n" 1641 | ] 1642 | } 1643 | ], 1644 | "source": [ 1645 | "# Create a computer variable i and assign the value 1 to it\n", 1646 | "i = 1\n", 1647 | "\n", 1648 | "# Create a while loop that runs as long as i is less than 5 and print i to the screen\n", 1649 | "while i < 5\n", 1650 | " println(i)\n", 1651 | " i += 1\n", 1652 | "end" 1653 | ] 1654 | }, 1655 | { 1656 | "cell_type": "markdown", 1657 | "metadata": {}, 1658 | "source": [ 1659 | "We do not see $5$. When the condition `i < 5` is evaluated and is `false` (that is when the value in `i` was incremented to $5$), the block of code is not executed. The value of the variable `i` is not printed to the screen. The `while` loop is exited." 1660 | ] 1661 | }, 1662 | { 1663 | "cell_type": "markdown", 1664 | "metadata": {}, 1665 | "source": [ 1666 | "### `if` statements in Julia" 1667 | ] 1668 | }, 1669 | { 1670 | "cell_type": "markdown", 1671 | "metadata": {}, 1672 | "source": [ 1673 | "We can control the flow of execution of code using `if` statements. The `if` statement is used to execute a block of code if a condition is `true`. The `if` statement is shown in the code cell below. The `if` keyword is followed by a condition that is evaluated. The block of code to be executed is indented and follows the `if` statement. The block of code is ended by the `end` keyword." 1674 | ] 1675 | }, 1676 | { 1677 | "cell_type": "code", 1678 | "execution_count": 44, 1679 | "metadata": {}, 1680 | "outputs": [ 1681 | { 1682 | "name": "stdout", 1683 | "output_type": "stream", 1684 | "text": [ 1685 | "1\n" 1686 | ] 1687 | } 1688 | ], 1689 | "source": [ 1690 | "# Create the computer variable i and assign the value 1 to it\n", 1691 | "i = 1\n", 1692 | "\n", 1693 | "# Use an if statement to check if i is less than 5 and of so print i to the screen\n", 1694 | "if i < 5\n", 1695 | " println(i)\n", 1696 | "end" 1697 | ] 1698 | }, 1699 | { 1700 | "cell_type": "markdown", 1701 | "metadata": {}, 1702 | "source": [ 1703 | "Since the value contained in the computer variable `i` is $1$, the condition `i < 5` is $1<5$ and that is `true`. The block of code is executed and the value of the variable `i` is printed to the screen." 1704 | ] 1705 | }, 1706 | { 1707 | "cell_type": "markdown", 1708 | "metadata": {}, 1709 | "source": [ 1710 | "We can add a block of code to be executed if the condition is `false`. This is done using the `else` keyword. The `else` keyword is followed by the block of code to be executed if the condition is `false`. The `else` block of code is indented and follows the `else` keyword. The `else` block of code is ended by the `end` keyword. We see this in the code cell below." 1711 | ] 1712 | }, 1713 | { 1714 | "cell_type": "code", 1715 | "execution_count": 45, 1716 | "metadata": {}, 1717 | "outputs": [ 1718 | { 1719 | "name": "stdout", 1720 | "output_type": "stream", 1721 | "text": [ 1722 | "i is not less than 5\n" 1723 | ] 1724 | } 1725 | ], 1726 | "source": [ 1727 | "# Create the computer variable i and assign the value 10 to it\n", 1728 | "i = 10\n", 1729 | "\n", 1730 | "# Use an if else statement to check if i is less than 5 and print i to the screen if it is\n", 1731 | "# If i is not less than 5 print \"i is not less than 5\" to the screen\n", 1732 | "if i < 5\n", 1733 | " println(i)\n", 1734 | "else\n", 1735 | " println(\"i is not less than 5\")\n", 1736 | "end" 1737 | ] 1738 | }, 1739 | { 1740 | "cell_type": "markdown", 1741 | "metadata": {}, 1742 | "source": [ 1743 | "Since the first conditional evaluated to `false`, the block of code in the `else` statement is executed. The clock of code in the `else` statement prints a string to the screen. More on strings later. This is a chicken-and-egg problem. We need to know about strings to understand the code, but we need to know about `if` statements to understand strings. We'll get there. We always do." 1744 | ] 1745 | }, 1746 | { 1747 | "cell_type": "markdown", 1748 | "metadata": {}, 1749 | "source": [ 1750 | "To make things really interesting we can nest the `elseif` statement inside the `if` statement. The `elseif` statement is used to evaluate another condition if the first condition is `false`. The `elseif` statement is shown in the code cell below. The `elseif` keyword is followed by a condition that is evaluated. The block of code to be executed is indented and follows the `elseif` statement. The block of code is ended by the `end` keyword." 1751 | ] 1752 | }, 1753 | { 1754 | "cell_type": "code", 1755 | "execution_count": 46, 1756 | "metadata": {}, 1757 | "outputs": [ 1758 | { 1759 | "name": "stdout", 1760 | "output_type": "stream", 1761 | "text": [ 1762 | "i is equal to 0\n" 1763 | ] 1764 | } 1765 | ], 1766 | "source": [ 1767 | "# Create the computer variable i and assign the value 0 to it\n", 1768 | "i = 0\n", 1769 | "\n", 1770 | "# Use an if else if else statement to check if i is less than 0 and print \"i is less than 0\" to the screen if it is\n", 1771 | "# If i is not less than 0 check if i is equal to 0 and print \"i is equal to 0\" to the screen if it is\n", 1772 | "# If i is not less than 0 and not equal to 0 print \"i is greater than 0\" to the screen\n", 1773 | "\n", 1774 | "if i < 0\n", 1775 | " println(\"i is less than 0\")\n", 1776 | "elseif i == 0\n", 1777 | " println(\"i is equal to 0\")\n", 1778 | "else\n", 1779 | " println(\"i is greater than 0\")\n", 1780 | "end" 1781 | ] 1782 | }, 1783 | { 1784 | "cell_type": "markdown", 1785 | "metadata": {}, 1786 | "source": [ 1787 | "## Data types in Julia" 1788 | ] 1789 | }, 1790 | { 1791 | "cell_type": "markdown", 1792 | "metadata": {}, 1793 | "source": [ 1794 | "### Built-in data types in Julia" 1795 | ] 1796 | }, 1797 | { 1798 | "cell_type": "markdown", 1799 | "metadata": {}, 1800 | "source": [ 1801 | "Time to pay the price for all the promises we have made. We start with the basic data types in Julia. The basic data types in Julia are shown in the table below." 1802 | ] 1803 | }, 1804 | { 1805 | "cell_type": "markdown", 1806 | "metadata": {}, 1807 | "source": [ 1808 | "| Data type | Description |\n", 1809 | "|-----------|-------------|\n", 1810 | "| `Int64` | Integer |\n", 1811 | "| `Float64` | Floating point number |\n", 1812 | "| `Bool` | Boolean value |\n", 1813 | "| `Char` | Character |\n", 1814 | "| `String` | String |\n", 1815 | "| `Complex` | Complex number |" 1816 | ] 1817 | }, 1818 | { 1819 | "cell_type": "markdown", 1820 | "metadata": {}, 1821 | "source": [ 1822 | "Note that this list is not exhaustive!" 1823 | ] 1824 | }, 1825 | { 1826 | "cell_type": "markdown", 1827 | "metadata": {}, 1828 | "source": [ 1829 | "The `typeof` function is used to determine the data type of a variable. The `typeof` function is shown in the code cell below to examine some of the basic data types in Julia in our table." 1830 | ] 1831 | }, 1832 | { 1833 | "cell_type": "code", 1834 | "execution_count": 47, 1835 | "metadata": {}, 1836 | "outputs": [ 1837 | { 1838 | "data": { 1839 | "text/plain": [ 1840 | "Int64" 1841 | ] 1842 | }, 1843 | "metadata": {}, 1844 | "output_type": "display_data" 1845 | } 1846 | ], 1847 | "source": [ 1848 | "# Determine the type of the value 1\n", 1849 | "typeof(1)" 1850 | ] 1851 | }, 1852 | { 1853 | "cell_type": "markdown", 1854 | "metadata": {}, 1855 | "source": [ 1856 | "We see `Int64` which is short for a $64$-bit integer. The bit size of the integer is important because it determines the range of values that the integer can take. The `Int64` data type can take values from $-2^{63}$ to $2^{63}-1$. There are also `Int32` and other bit size integers. The interval of values for `Int64` begs the question _What happens if we try to assign a value outside the range of the data type?_ Let's looks at $2^{63}$ (without the $-1$) and see what happens." 1857 | ] 1858 | }, 1859 | { 1860 | "cell_type": "code", 1861 | "execution_count": 48, 1862 | "metadata": {}, 1863 | "outputs": [ 1864 | { 1865 | "data": { 1866 | "text/plain": [ 1867 | "-9223372036854775808" 1868 | ] 1869 | }, 1870 | "metadata": {}, 1871 | "output_type": "display_data" 1872 | } 1873 | ], 1874 | "source": [ 1875 | "# Calculate 2^63\n", 1876 | "2^63" 1877 | ] 1878 | }, 1879 | { 1880 | "cell_type": "markdown", 1881 | "metadata": {}, 1882 | "source": [ 1883 | "Yes, we _wrap around_ to the smallest number. Neat. To make sure, let's look at $-2^{63}$." 1884 | ] 1885 | }, 1886 | { 1887 | "cell_type": "code", 1888 | "execution_count": 49, 1889 | "metadata": {}, 1890 | "outputs": [ 1891 | { 1892 | "data": { 1893 | "text/plain": [ 1894 | "-9223372036854775808" 1895 | ] 1896 | }, 1897 | "metadata": {}, 1898 | "output_type": "display_data" 1899 | } 1900 | ], 1901 | "source": [ 1902 | "-2^63" 1903 | ] 1904 | }, 1905 | { 1906 | "cell_type": "markdown", 1907 | "metadata": {}, 1908 | "source": [ 1909 | "Next, we interrogate the `Float64` data type. The `Float64` data type is a floating point number. The `Float64` data type can take values from $-2^{1023}$ to $2^{1023}$." 1910 | ] 1911 | }, 1912 | { 1913 | "cell_type": "code", 1914 | "execution_count": 50, 1915 | "metadata": {}, 1916 | "outputs": [ 1917 | { 1918 | "data": { 1919 | "text/plain": [ 1920 | "Float64" 1921 | ] 1922 | }, 1923 | "metadata": {}, 1924 | "output_type": "display_data" 1925 | } 1926 | ], 1927 | "source": [ 1928 | "# Determine the type of the value 1.0\n", 1929 | "typeof(1.0)" 1930 | ] 1931 | }, 1932 | { 1933 | "cell_type": "markdown", 1934 | "metadata": {}, 1935 | "source": [ 1936 | "What about the `Bool` data type? The `Bool` data type is a Boolean value. The `Bool` data type can take the values `true` or `false`." 1937 | ] 1938 | }, 1939 | { 1940 | "cell_type": "code", 1941 | "execution_count": 51, 1942 | "metadata": {}, 1943 | "outputs": [ 1944 | { 1945 | "data": { 1946 | "text/plain": [ 1947 | "Bool" 1948 | ] 1949 | }, 1950 | "metadata": {}, 1951 | "output_type": "display_data" 1952 | } 1953 | ], 1954 | "source": [ 1955 | "# Determine the type of true\n", 1956 | "typeof(true)" 1957 | ] 1958 | }, 1959 | { 1960 | "cell_type": "markdown", 1961 | "metadata": {}, 1962 | "source": [ 1963 | "`Bool` is short for Boolean." 1964 | ] 1965 | }, 1966 | { 1967 | "cell_type": "markdown", 1968 | "metadata": {}, 1969 | "source": [ 1970 | "What about a single letter (whci we surround with single quotes `'`)?" 1971 | ] 1972 | }, 1973 | { 1974 | "cell_type": "code", 1975 | "execution_count": 52, 1976 | "metadata": {}, 1977 | "outputs": [ 1978 | { 1979 | "data": { 1980 | "text/plain": [ 1981 | "Char" 1982 | ] 1983 | }, 1984 | "metadata": {}, 1985 | "output_type": "display_data" 1986 | } 1987 | ], 1988 | "source": [ 1989 | "# Determine the type of the letter J\n", 1990 | "typeof('J')" 1991 | ] 1992 | }, 1993 | { 1994 | "cell_type": "markdown", 1995 | "metadata": {}, 1996 | "source": [ 1997 | "This is a `Char` data type. The `Char` data type is a character. The `Char` data type can take a single character." 1998 | ] 1999 | }, 2000 | { 2001 | "cell_type": "markdown", 2002 | "metadata": {}, 2003 | "source": [ 2004 | "What about a word (also wrapped in single quotes `'`)?" 2005 | ] 2006 | }, 2007 | { 2008 | "cell_type": "code", 2009 | "execution_count": 53, 2010 | "metadata": {}, 2011 | "outputs": [ 2012 | { 2013 | "data": { 2014 | "text/plain": [ 2015 | "String" 2016 | ] 2017 | }, 2018 | "metadata": {}, 2019 | "output_type": "display_data" 2020 | } 2021 | ], 2022 | "source": [ 2023 | "# Determine the type of the word \"Julia\"\n", 2024 | "typeof(\"Julia\")" 2025 | ] 2026 | }, 2027 | { 2028 | "cell_type": "markdown", 2029 | "metadata": {}, 2030 | "source": [ 2031 | "This is a `String` data type. The `String` data type is a string. The `String` data type can take a sequence of characters." 2032 | ] 2033 | }, 2034 | { 2035 | "cell_type": "markdown", 2036 | "metadata": {}, 2037 | "source": [ 2038 | "Just for fun, what about `1+1im`?" 2039 | ] 2040 | }, 2041 | { 2042 | "cell_type": "code", 2043 | "execution_count": 54, 2044 | "metadata": {}, 2045 | "outputs": [ 2046 | { 2047 | "data": { 2048 | "text/plain": [ 2049 | "Complex{Int64}" 2050 | ] 2051 | }, 2052 | "metadata": {}, 2053 | "output_type": "display_data" 2054 | } 2055 | ], 2056 | "source": [ 2057 | "# Determine the type of the value 1 + 1im\n", 2058 | "typeof(1 + 1im)" 2059 | ] 2060 | }, 2061 | { 2062 | "cell_type": "markdown", 2063 | "metadata": {}, 2064 | "source": [ 2065 | "`Complex{Int64}` refers to the fact that we have a complex number with integer real and imaginary values." 2066 | ] 2067 | }, 2068 | { 2069 | "cell_type": "markdown", 2070 | "metadata": {}, 2071 | "source": [ 2072 | "### Type structure in Julia" 2073 | ] 2074 | }, 2075 | { 2076 | "cell_type": "markdown", 2077 | "metadata": {}, 2078 | "source": [ 2079 | "Julia has a type hierarchy. This means that data types are related to each other. At the top of the hierarchy sits the `Any` type. All types are subtypes of teh `Any` data type." 2080 | ] 2081 | }, 2082 | { 2083 | "cell_type": "code", 2084 | "execution_count": 80, 2085 | "metadata": {}, 2086 | "outputs": [ 2087 | { 2088 | "data": { 2089 | "text/plain": [ 2090 | "DataType" 2091 | ] 2092 | }, 2093 | "metadata": {}, 2094 | "output_type": "display_data" 2095 | } 2096 | ], 2097 | "source": [ 2098 | "# Type of Any\n", 2099 | "typeof(Any)" 2100 | ] 2101 | }, 2102 | { 2103 | "cell_type": "markdown", 2104 | "metadata": {}, 2105 | "source": [ 2106 | "We can list all the subtypes of a data type using the `subtypes` function. The `subtypes` function is shown in the code cell below. Since we call the `Any` type, we see a long (truncated) list of Julia data types." 2107 | ] 2108 | }, 2109 | { 2110 | "cell_type": "code", 2111 | "execution_count": 81, 2112 | "metadata": {}, 2113 | "outputs": [ 2114 | { 2115 | "data": { 2116 | "text/plain": [ 2117 | "635-element Vector{Any}:\n", 2118 | " AbstractArray\n", 2119 | " AbstractChannel\n", 2120 | " AbstractChar\n", 2121 | " AbstractDict\n", 2122 | " AbstractDisplay\n", 2123 | " AbstractMatch\n", 2124 | " AbstractPattern\n", 2125 | " AbstractSet\n", 2126 | " AbstractString\n", 2127 | " Any\n", 2128 | " ⋮\n", 2129 | " VSCodeServer.SignatureHelpContext\n", 2130 | " VSCodeServer.SignatureInformation\n", 2131 | " VSCodeServer.SubTree\n", 2132 | " VSCodeServer.Undef\n", 2133 | " VSCodeServer.Wrapper\n", 2134 | " Val\n", 2135 | " VecElement\n", 2136 | " VersionNumber\n", 2137 | " WeakRef" 2138 | ] 2139 | }, 2140 | "metadata": {}, 2141 | "output_type": "display_data" 2142 | } 2143 | ], 2144 | "source": [ 2145 | "# Subtypes of Any\n", 2146 | "subtypes(Any)" 2147 | ] 2148 | }, 2149 | { 2150 | "cell_type": "markdown", 2151 | "metadata": {}, 2152 | "source": [ 2153 | "By passing `subtypes(Any)` as argument to the `length` function, we can see how many subtypes there are of the `Any` data type." 2154 | ] 2155 | }, 2156 | { 2157 | "cell_type": "code", 2158 | "execution_count": 82, 2159 | "metadata": {}, 2160 | "outputs": [ 2161 | { 2162 | "data": { 2163 | "text/plain": [ 2164 | "635" 2165 | ] 2166 | }, 2167 | "metadata": {}, 2168 | "output_type": "display_data" 2169 | } 2170 | ], 2171 | "source": [ 2172 | "# Number of types\n", 2173 | "length(subtypes(Any))" 2174 | ] 2175 | }, 2176 | { 2177 | "cell_type": "markdown", 2178 | "metadata": {}, 2179 | "source": [ 2180 | "That is quite a few data types. This makes Julia a very versatile language indeed." 2181 | ] 2182 | }, 2183 | { 2184 | "cell_type": "markdown", 2185 | "metadata": {}, 2186 | "source": [ 2187 | "One of the subtypes of the `Any` data type is the `AbstractFloat` type. Below, we look at the list of subtypes of the `AbstractFloat` data type." 2188 | ] 2189 | }, 2190 | { 2191 | "cell_type": "code", 2192 | "execution_count": 85, 2193 | "metadata": {}, 2194 | "outputs": [ 2195 | { 2196 | "data": { 2197 | "text/plain": [ 2198 | "4-element Vector{Any}:\n", 2199 | " BigFloat\n", 2200 | " Float16\n", 2201 | " Float32\n", 2202 | " Float64" 2203 | ] 2204 | }, 2205 | "metadata": {}, 2206 | "output_type": "display_data" 2207 | } 2208 | ], 2209 | "source": [ 2210 | "# Subtypes of AbstractFloat\n", 2211 | "subtypes(AbstractFloat)" 2212 | ] 2213 | }, 2214 | { 2215 | "cell_type": "markdown", 2216 | "metadata": {}, 2217 | "source": [ 2218 | "This is where we find all the bit length floating point data types." 2219 | ] 2220 | }, 2221 | { 2222 | "cell_type": "markdown", 2223 | "metadata": {}, 2224 | "source": [ 2225 | "Any data type in the Julia type hierarchy (except for the `Any` type which sists at the top) has a supertype. The supertype of a data type is the data type that is one level above it in the type hierarchy. The `supertype` function is used to determine the supertype of a data type. The `supertype` function is shown in the code cell below." 2226 | ] 2227 | }, 2228 | { 2229 | "cell_type": "code", 2230 | "execution_count": 86, 2231 | "metadata": {}, 2232 | "outputs": [ 2233 | { 2234 | "data": { 2235 | "text/plain": [ 2236 | "Real" 2237 | ] 2238 | }, 2239 | "metadata": {}, 2240 | "output_type": "display_data" 2241 | } 2242 | ], 2243 | "source": [ 2244 | "# Supertype of AbstractFloat\n", 2245 | "supertype(AbstractFloat)" 2246 | ] 2247 | }, 2248 | { 2249 | "cell_type": "markdown", 2250 | "metadata": {}, 2251 | "source": [ 2252 | "We see that the supertype of the `AbstractFloat` data type is the `Real` data type. We can also look at the supertype of the `Real` data type." 2253 | ] 2254 | }, 2255 | { 2256 | "cell_type": "code", 2257 | "execution_count": 88, 2258 | "metadata": {}, 2259 | "outputs": [ 2260 | { 2261 | "data": { 2262 | "text/plain": [ 2263 | "Number" 2264 | ] 2265 | }, 2266 | "metadata": {}, 2267 | "output_type": "display_data" 2268 | } 2269 | ], 2270 | "source": [ 2271 | "# Supertype of Real\n", 2272 | "supertype(Real)" 2273 | ] 2274 | }, 2275 | { 2276 | "cell_type": "markdown", 2277 | "metadata": {}, 2278 | "source": [ 2279 | "It is the `Number` type. Below we see the supertype of the `Number` data type, which is the top-level `Any` data type." 2280 | ] 2281 | }, 2282 | { 2283 | "cell_type": "code", 2284 | "execution_count": 89, 2285 | "metadata": {}, 2286 | "outputs": [ 2287 | { 2288 | "data": { 2289 | "text/plain": [ 2290 | "Any" 2291 | ] 2292 | }, 2293 | "metadata": {}, 2294 | "output_type": "display_data" 2295 | } 2296 | ], 2297 | "source": [ 2298 | "# Supertype of Number\n", 2299 | "supertype(Number)" 2300 | ] 2301 | }, 2302 | { 2303 | "cell_type": "markdown", 2304 | "metadata": {}, 2305 | "source": [ 2306 | "By using teh `subtype` and `supertype` functions, we can navigate the Julia type hierarchy." 2307 | ] 2308 | }, 2309 | { 2310 | "cell_type": "markdown", 2311 | "metadata": {}, 2312 | "source": [ 2313 | "### Type construction in Julia" 2314 | ] 2315 | }, 2316 | { 2317 | "cell_type": "markdown", 2318 | "metadata": {}, 2319 | "source": [ 2320 | "Julia allows us to construct our own types. We can define a new type using the `struct` keyword. The `struct` keyword is followed by the name of the type. The name of the type is capitalized. The name of the type is followed by the keyword `end`. The `struct` keyword is used in the code cell below where we create a type called `BloodPressure` which contains two fields named `systolic` and `diastolic`. We specify the data type that these two fields will take. To do this we use double colon symbols and then the type." 2321 | ] 2322 | }, 2323 | { 2324 | "cell_type": "code", 2325 | "execution_count": 90, 2326 | "metadata": {}, 2327 | "outputs": [], 2328 | "source": [ 2329 | "# Construct a type called BloodPressure with two fields, systolic and diastolic each of which are integers\n", 2330 | "struct BloodPressure\n", 2331 | " systolic::Int\n", 2332 | " diastolic::Int\n", 2333 | "end" 2334 | ] 2335 | }, 2336 | { 2337 | "cell_type": "markdown", 2338 | "metadata": {}, 2339 | "source": [ 2340 | "We confirm that `BloodPressure` is a `DatatType` type by using the `typeof` function." 2341 | ] 2342 | }, 2343 | { 2344 | "cell_type": "code", 2345 | "execution_count": 91, 2346 | "metadata": {}, 2347 | "outputs": [ 2348 | { 2349 | "data": { 2350 | "text/plain": [ 2351 | "DataType" 2352 | ] 2353 | }, 2354 | "metadata": {}, 2355 | "output_type": "display_data" 2356 | } 2357 | ], 2358 | "source": [ 2359 | "# Type of BloodPressure\n", 2360 | "typeof(BloodPressure)" 2361 | ] 2362 | }, 2363 | { 2364 | "cell_type": "markdown", 2365 | "metadata": {}, 2366 | "source": [ 2367 | "By default `struct` creates a type that is a subtype of `Any`. the `supertype` function confirms this." 2368 | ] 2369 | }, 2370 | { 2371 | "cell_type": "code", 2372 | "execution_count": 92, 2373 | "metadata": {}, 2374 | "outputs": [ 2375 | { 2376 | "data": { 2377 | "text/plain": [ 2378 | "Any" 2379 | ] 2380 | }, 2381 | "metadata": {}, 2382 | "output_type": "display_data" 2383 | } 2384 | ], 2385 | "source": [ 2386 | "# Supertype of BloodPressure\n", 2387 | "supertype(BloodPressure)" 2388 | ] 2389 | }, 2390 | { 2391 | "cell_type": "markdown", 2392 | "metadata": {}, 2393 | "source": [ 2394 | "We can now instantiate the type. Below we create a new variable `bp` and use the `BloodPressure` type to create a new instance of the type. We assign values to the fields `systolic` and `diastolic`." 2395 | ] 2396 | }, 2397 | { 2398 | "cell_type": "code", 2399 | "execution_count": 93, 2400 | "metadata": {}, 2401 | "outputs": [ 2402 | { 2403 | "data": { 2404 | "text/plain": [ 2405 | "BloodPressure(120, 80)" 2406 | ] 2407 | }, 2408 | "metadata": {}, 2409 | "output_type": "display_data" 2410 | } 2411 | ], 2412 | "source": [ 2413 | "# Instantiate the BloodPressure type with field values 120, 80 and assign it to the variable bp\n", 2414 | "bp = BloodPressure(120, 80)" 2415 | ] 2416 | }, 2417 | { 2418 | "cell_type": "markdown", 2419 | "metadata": {}, 2420 | "source": [ 2421 | "The field names can be used to access the values of the fields using dot notation." 2422 | ] 2423 | }, 2424 | { 2425 | "cell_type": "code", 2426 | "execution_count": 94, 2427 | "metadata": {}, 2428 | "outputs": [ 2429 | { 2430 | "data": { 2431 | "text/plain": [ 2432 | "120" 2433 | ] 2434 | }, 2435 | "metadata": {}, 2436 | "output_type": "display_data" 2437 | } 2438 | ], 2439 | "source": [ 2440 | "# Return the systolic field value in the bp variable\n", 2441 | "bp.systolic" 2442 | ] 2443 | }, 2444 | { 2445 | "cell_type": "markdown", 2446 | "metadata": {}, 2447 | "source": [ 2448 | "By default, the `struct` constructor creates an immutable type. This means that the values of the fields cannot be changed once instantiated. We can change this by using the `mutable struct` keyword. The `mutable struct` keyword is used in the code cell below to create a mutable type called `MutableBloodPressure`." 2449 | ] 2450 | }, 2451 | { 2452 | "cell_type": "code", 2453 | "execution_count": 96, 2454 | "metadata": {}, 2455 | "outputs": [], 2456 | "source": [ 2457 | "# Create a mutable struct called BloodPressureMutable with two fields, systolic and diastolic each of which are integers\n", 2458 | "mutable struct BloodPressureMutable\n", 2459 | " systolic::Int\n", 2460 | " diastolic::Int\n", 2461 | "end" 2462 | ] 2463 | }, 2464 | { 2465 | "cell_type": "markdown", 2466 | "metadata": {}, 2467 | "source": [ 2468 | "Now we can instantiate the type and change the values of the fields." 2469 | ] 2470 | }, 2471 | { 2472 | "cell_type": "code", 2473 | "execution_count": 97, 2474 | "metadata": {}, 2475 | "outputs": [ 2476 | { 2477 | "data": { 2478 | "text/plain": [ 2479 | "BloodPressureMutable(120, 80)" 2480 | ] 2481 | }, 2482 | "metadata": {}, 2483 | "output_type": "display_data" 2484 | } 2485 | ], 2486 | "source": [ 2487 | "# Instantiate the BloodPressureMutable type with field values 120, 80 and assign it to the variable bpm\n", 2488 | "bpm = BloodPressureMutable(120, 80)" 2489 | ] 2490 | }, 2491 | { 2492 | "cell_type": "code", 2493 | "execution_count": 98, 2494 | "metadata": {}, 2495 | "outputs": [ 2496 | { 2497 | "data": { 2498 | "text/plain": [ 2499 | "130" 2500 | ] 2501 | }, 2502 | "metadata": {}, 2503 | "output_type": "display_data" 2504 | } 2505 | ], 2506 | "source": [ 2507 | "# Reassign the systolic field value to 130 in the bpm variable\n", 2508 | "bpm.systolic = 130" 2509 | ] 2510 | }, 2511 | { 2512 | "cell_type": "markdown", 2513 | "metadata": {}, 2514 | "source": [ 2515 | "Types in Julia can also take parameters. As example, we might want our `BloodPressure` type to not only be mutable, but also take a parameter that specifies a type or a supertype. Below we create a new type `BloodPressureReal` that takes a parameter `T` such that the field types can be `Real` or any of it subtypes." 2516 | ] 2517 | }, 2518 | { 2519 | "cell_type": "code", 2520 | "execution_count": 100, 2521 | "metadata": {}, 2522 | "outputs": [], 2523 | "source": [ 2524 | "# Construct a type called BloodPressureReal with two fields, systolic and diastolic each of which are reals\n", 2525 | "mutable struct BloodPressureReal{T<:Real}\n", 2526 | " systolic::T\n", 2527 | " diastolic::T\n", 2528 | "end" 2529 | ] 2530 | }, 2531 | { 2532 | "cell_type": "markdown", 2533 | "metadata": {}, 2534 | "source": [ 2535 | "While the fields of the `BloodPressureReal` are set to be real number, we can still pass integer values because we specified a parameter that has `Real` as supertype and `Int64` is a subtype of `Real`." 2536 | ] 2537 | }, 2538 | { 2539 | "cell_type": "code", 2540 | "execution_count": 102, 2541 | "metadata": {}, 2542 | "outputs": [ 2543 | { 2544 | "data": { 2545 | "text/plain": [ 2546 | "BloodPressureReal{Int64}(120, 80)" 2547 | ] 2548 | }, 2549 | "metadata": {}, 2550 | "output_type": "display_data" 2551 | } 2552 | ], 2553 | "source": [ 2554 | "# Create a BloodPressureReal object with field values 120, 80 and assign it to the variable bpr\n", 2555 | "bpr = BloodPressureReal(120, 80)" 2556 | ] 2557 | }, 2558 | { 2559 | "cell_type": "markdown", 2560 | "metadata": {}, 2561 | "source": [ 2562 | "## Data structures in Julia" 2563 | ] 2564 | }, 2565 | { 2566 | "cell_type": "markdown", 2567 | "metadata": {}, 2568 | "source": [ 2569 | "### Array objects in Julia" 2570 | ] 2571 | }, 2572 | { 2573 | "cell_type": "markdown", 2574 | "metadata": {}, 2575 | "source": [ 2576 | "Arrays in Julia are used to store collections of values and created using square brackets `[]`. The values in an array are separated by commas. The array object `[1, 2, 3]` is shown in the code cell below." 2577 | ] 2578 | }, 2579 | { 2580 | "cell_type": "code", 2581 | "execution_count": 55, 2582 | "metadata": {}, 2583 | "outputs": [ 2584 | { 2585 | "data": { 2586 | "text/plain": [ 2587 | "3-element Vector{Int64}:\n", 2588 | " 1\n", 2589 | " 2\n", 2590 | " 3" 2591 | ] 2592 | }, 2593 | "metadata": {}, 2594 | "output_type": "display_data" 2595 | } 2596 | ], 2597 | "source": [ 2598 | "# Create a list of the elements 1, 2, 3\n", 2599 | "[1, 2, 3]" 2600 | ] 2601 | }, 2602 | { 2603 | "cell_type": "markdown", 2604 | "metadata": {}, 2605 | "source": [ 2606 | "Not only do we see that we have the three elements written as a column vector, but we also see that this is a three-element vector of integers. Let's see what the `typeof` function makes of this." 2607 | ] 2608 | }, 2609 | { 2610 | "cell_type": "code", 2611 | "execution_count": 56, 2612 | "metadata": {}, 2613 | "outputs": [ 2614 | { 2615 | "data": { 2616 | "text/plain": [ 2617 | "Vector{Int64}\u001b[90m (alias for \u001b[39m\u001b[90mArray{Int64, 1}\u001b[39m\u001b[90m)\u001b[39m" 2618 | ] 2619 | }, 2620 | "metadata": {}, 2621 | "output_type": "display_data" 2622 | } 2623 | ], 2624 | "source": [ 2625 | "# Determine the type of the list [1, 2, 3]\n", 2626 | "typeof([1, 2, 3])" 2627 | ] 2628 | }, 2629 | { 2630 | "cell_type": "markdown", 2631 | "metadata": {}, 2632 | "source": [ 2633 | "An array object has a length which is the number of elements in the array. The `length` function (which we have already seen) is used to determine the length of an array. The `length` function is shown in the code cell below." 2634 | ] 2635 | }, 2636 | { 2637 | "cell_type": "code", 2638 | "execution_count": 57, 2639 | "metadata": {}, 2640 | "outputs": [ 2641 | { 2642 | "data": { 2643 | "text/plain": [ 2644 | "3" 2645 | ] 2646 | }, 2647 | "metadata": {}, 2648 | "output_type": "display_data" 2649 | } 2650 | ], 2651 | "source": [ 2652 | "# Determine the length of the array [1, 2, 3]\n", 2653 | "length([1, 2, 3])" 2654 | ] 2655 | }, 2656 | { 2657 | "cell_type": "markdown", 2658 | "metadata": {}, 2659 | "source": [ 2660 | "We can determine if a specific value is in an array using the `in` keyword. Below, we determine if the number $3$ is in the array `[1, 2, 3]` and if the number $4$ is in the array `[1, 2, 3]`." 2661 | ] 2662 | }, 2663 | { 2664 | "cell_type": "code", 2665 | "execution_count": 58, 2666 | "metadata": {}, 2667 | "outputs": [ 2668 | { 2669 | "data": { 2670 | "text/plain": [ 2671 | "true" 2672 | ] 2673 | }, 2674 | "metadata": {}, 2675 | "output_type": "display_data" 2676 | } 2677 | ], 2678 | "source": [ 2679 | "# Determine if 3 is in the array [1, 2, 3]\n", 2680 | "3 in [1, 2, 3]" 2681 | ] 2682 | }, 2683 | { 2684 | "cell_type": "code", 2685 | "execution_count": 59, 2686 | "metadata": {}, 2687 | "outputs": [ 2688 | { 2689 | "data": { 2690 | "text/plain": [ 2691 | "false" 2692 | ] 2693 | }, 2694 | "metadata": {}, 2695 | "output_type": "display_data" 2696 | } 2697 | ], 2698 | "source": [ 2699 | "# Determine if 4 is in the array [1, 2, 3]\n", 2700 | "4 in [1, 2, 3]" 2701 | ] 2702 | }, 2703 | { 2704 | "cell_type": "markdown", 2705 | "metadata": {}, 2706 | "source": [ 2707 | "The $\\in$ symbol can be used as shorthand for the `in` keyword. We create the symbol by typing `\\in` and hitting the TAB key. Below we repeat the previous example using the $\\in$ symbol." 2708 | ] 2709 | }, 2710 | { 2711 | "cell_type": "code", 2712 | "execution_count": 60, 2713 | "metadata": {}, 2714 | "outputs": [ 2715 | { 2716 | "data": { 2717 | "text/plain": [ 2718 | "false" 2719 | ] 2720 | }, 2721 | "metadata": {}, 2722 | "output_type": "display_data" 2723 | } 2724 | ], 2725 | "source": [ 2726 | "# Determine if 4 is not in the array [1, 2, 3]\n", 2727 | "4 ∈ [1, 2, 3]" 2728 | ] 2729 | }, 2730 | { 2731 | "cell_type": "markdown", 2732 | "metadata": {}, 2733 | "source": [ 2734 | "The $\\notin$ symbol can be used to determine if a value is not in an array. We create the symbol by typing `\\notin` and hitting the TAB key. Below we determine if the number $4$ is not in the array `[1, 2, 3]`." 2735 | ] 2736 | }, 2737 | { 2738 | "cell_type": "code", 2739 | "execution_count": 61, 2740 | "metadata": {}, 2741 | "outputs": [ 2742 | { 2743 | "data": { 2744 | "text/plain": [ 2745 | "true" 2746 | ] 2747 | }, 2748 | "metadata": {}, 2749 | "output_type": "display_data" 2750 | } 2751 | ], 2752 | "source": [ 2753 | "# Determine of 4 is not in the array [1, 2, 3]\n", 2754 | "4 ∉ [1, 2, 3]" 2755 | ] 2756 | }, 2757 | { 2758 | "cell_type": "markdown", 2759 | "metadata": {}, 2760 | "source": [ 2761 | "The `isempty` function is used to determine if an array is empty. The `isempty` function is shown in the code cell below to determine if the array `[]` is empty, which it obviously is." 2762 | ] 2763 | }, 2764 | { 2765 | "cell_type": "code", 2766 | "execution_count": 62, 2767 | "metadata": {}, 2768 | "outputs": [ 2769 | { 2770 | "data": { 2771 | "text/plain": [ 2772 | "true" 2773 | ] 2774 | }, 2775 | "metadata": {}, 2776 | "output_type": "display_data" 2777 | } 2778 | ], 2779 | "source": [ 2780 | "# Determine if the array [] is empty\n", 2781 | "isempty([])" 2782 | ] 2783 | }, 2784 | { 2785 | "cell_type": "markdown", 2786 | "metadata": {}, 2787 | "source": [ 2788 | "When dealing with arrays, we may want to determine the unique values in an array. The `unique` function is used to determine the unique values in an array." 2789 | ] 2790 | }, 2791 | { 2792 | "cell_type": "code", 2793 | "execution_count": 63, 2794 | "metadata": {}, 2795 | "outputs": [ 2796 | { 2797 | "data": { 2798 | "text/plain": [ 2799 | "3-element Vector{Int64}:\n", 2800 | " 1\n", 2801 | " 2\n", 2802 | " 3" 2803 | ] 2804 | }, 2805 | "metadata": {}, 2806 | "output_type": "display_data" 2807 | } 2808 | ], 2809 | "source": [ 2810 | "# Determine the unique elements in the array [1, 2, 2, 3, 3, 3]\n", 2811 | "unique([1, 2, 2, 3, 3, 3])" 2812 | ] 2813 | }, 2814 | { 2815 | "cell_type": "markdown", 2816 | "metadata": {}, 2817 | "source": [ 2818 | "The `allunique` function is used to determine if all the values in an array are unique. We use the previous array again using the `allunique` function. Since we are repeating some elements, the function should return `false`." 2819 | ] 2820 | }, 2821 | { 2822 | "cell_type": "code", 2823 | "execution_count": 64, 2824 | "metadata": {}, 2825 | "outputs": [ 2826 | { 2827 | "data": { 2828 | "text/plain": [ 2829 | "false" 2830 | ] 2831 | }, 2832 | "metadata": {}, 2833 | "output_type": "display_data" 2834 | } 2835 | ], 2836 | "source": [ 2837 | "# Determine if all the elements in the array [1, 2, 2, 3, 3, 3] are unique\n", 2838 | "allunique([1, 2, 2, 3, 3, 3])" 2839 | ] 2840 | }, 2841 | { 2842 | "cell_type": "markdown", 2843 | "metadata": {}, 2844 | "source": [ 2845 | "Arrays can also be created as row vectors. To do this we add spaces between the elements of the array. The row vector `[1 2 3]` is shown in the code cell below." 2846 | ] 2847 | }, 2848 | { 2849 | "cell_type": "code", 2850 | "execution_count": 65, 2851 | "metadata": {}, 2852 | "outputs": [ 2853 | { 2854 | "data": { 2855 | "text/plain": [ 2856 | "1×3 Matrix{Int64}:\n", 2857 | " 1 2 3" 2858 | ] 2859 | }, 2860 | "metadata": {}, 2861 | "output_type": "display_data" 2862 | } 2863 | ], 2864 | "source": [ 2865 | "# Create the array [1 2 3]\n", 2866 | "[1 2 3]" 2867 | ] 2868 | }, 2869 | { 2870 | "cell_type": "markdown", 2871 | "metadata": {}, 2872 | "source": [ 2873 | "Julia returns a `Matrix` object. When we use the `typeof` function we see that it is actually and `Array` of integers along a second axis (columns)." 2874 | ] 2875 | }, 2876 | { 2877 | "cell_type": "code", 2878 | "execution_count": 66, 2879 | "metadata": {}, 2880 | "outputs": [ 2881 | { 2882 | "data": { 2883 | "text/plain": [ 2884 | "Matrix{Int64}\u001b[90m (alias for \u001b[39m\u001b[90mArray{Int64, 2}\u001b[39m\u001b[90m)\u001b[39m" 2885 | ] 2886 | }, 2887 | "metadata": {}, 2888 | "output_type": "display_data" 2889 | } 2890 | ], 2891 | "source": [ 2892 | "# Determine the type of the array [1 2 3]\n", 2893 | "typeof([1 2 3])" 2894 | ] 2895 | }, 2896 | { 2897 | "cell_type": "markdown", 2898 | "metadata": {}, 2899 | "source": [ 2900 | "We note that the elements are placed along the first row in three columns. A `Matrix` object is a two-dimensional array. The `Matrix` object is a special case of an `Array` object. The `Matrix` object is a two-dimensional array with rows and columns. We can create a `Matrix` object by specifying the values along each row (separated by spaces) and separating the rows by semicolons." 2901 | ] 2902 | }, 2903 | { 2904 | "cell_type": "code", 2905 | "execution_count": 67, 2906 | "metadata": {}, 2907 | "outputs": [ 2908 | { 2909 | "data": { 2910 | "text/plain": [ 2911 | "2×3 Matrix{Int64}:\n", 2912 | " 1 2 3\n", 2913 | " 4 5 6" 2914 | ] 2915 | }, 2916 | "metadata": {}, 2917 | "output_type": "display_data" 2918 | } 2919 | ], 2920 | "source": [ 2921 | "# Create a matrix with two rows and three columns using the values 1, 2, 3, 4, 5, 6\n", 2922 | "[1 2 3; 4 5 6]" 2923 | ] 2924 | }, 2925 | { 2926 | "cell_type": "markdown", 2927 | "metadata": {}, 2928 | "source": [ 2929 | "The `reshape` function is used to change the shape of an array. The `reshape` function is shown in the code cell below to change the shape of the array `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]` to a $3 \\times 4$ `Matrix` object. Note that instead of typing all the elements, we use a `UnitRange` object `1:12` to represent the values $1$ through $12$." 2930 | ] 2931 | }, 2932 | { 2933 | "cell_type": "code", 2934 | "execution_count": 68, 2935 | "metadata": {}, 2936 | "outputs": [ 2937 | { 2938 | "data": { 2939 | "text/plain": [ 2940 | "3×4 reshape(::UnitRange{Int64}, 3, 4) with eltype Int64:\n", 2941 | " 1 4 7 10\n", 2942 | " 2 5 8 11\n", 2943 | " 3 6 9 12" 2944 | ] 2945 | }, 2946 | "metadata": {}, 2947 | "output_type": "display_data" 2948 | } 2949 | ], 2950 | "source": [ 2951 | "# Use the reshape function to create a 3x4 matrix from the unit range object 1:12\n", 2952 | "reshape(1:12, 3, 4)" 2953 | ] 2954 | }, 2955 | { 2956 | "cell_type": "markdown", 2957 | "metadata": {}, 2958 | "source": [ 2959 | "Note the difference between the last two objects that we created. In the second, the values are distributed along the columns." 2960 | ] 2961 | }, 2962 | { 2963 | "cell_type": "markdown", 2964 | "metadata": {}, 2965 | "source": [ 2966 | "The `size` function determines the number of rows and columns of an `Array` object. The `size` function is shown in the code cell below to determine the size of the `Matrix` object `reshape(1:12, 3, 4)`." 2967 | ] 2968 | }, 2969 | { 2970 | "cell_type": "code", 2971 | "execution_count": 69, 2972 | "metadata": {}, 2973 | "outputs": [ 2974 | { 2975 | "data": { 2976 | "text/plain": [ 2977 | "(3, 4)" 2978 | ] 2979 | }, 2980 | "metadata": {}, 2981 | "output_type": "display_data" 2982 | } 2983 | ], 2984 | "source": [ 2985 | "# Determine the size of the matrix reshape(1:12, 3, 4)\n", 2986 | "size(reshape(1:12, 3, 4))" 2987 | ] 2988 | }, 2989 | { 2990 | "cell_type": "markdown", 2991 | "metadata": {}, 2992 | "source": [ 2993 | "Julia returns a tuple (coming shortly) with the number of rows and columns." 2994 | ] 2995 | }, 2996 | { 2997 | "cell_type": "markdown", 2998 | "metadata": {}, 2999 | "source": [ 3000 | "Every elements in an array has an address called an index. For an `Array` object along rows and columns, each index will be a row and a column value. Indices in Julia start at $1$. The value at a specific index can be accessed using square brackets `[]`. The value at the index $(2, 3)$ of the `Matrix` object `reshape(1:12, 3, 4)` is shown in the code cell below." 3001 | ] 3002 | }, 3003 | { 3004 | "cell_type": "code", 3005 | "execution_count": 70, 3006 | "metadata": {}, 3007 | "outputs": [ 3008 | { 3009 | "data": { 3010 | "text/plain": [ 3011 | "8" 3012 | ] 3013 | }, 3014 | "metadata": {}, 3015 | "output_type": "display_data" 3016 | } 3017 | ], 3018 | "source": [ 3019 | "# Determine the value in the second row of the third column of the matrix reshape(1:12, 3, 4)\n", 3020 | "reshape(1:12, 3, 4)[2, 3]" 3021 | ] 3022 | }, 3023 | { 3024 | "cell_type": "markdown", 3025 | "metadata": {}, 3026 | "source": [ 3027 | "Julia returns the value $8$ which is the value at the index $(2, 3)$ of the `Matrix` object `reshape(1:12, 3, 4)`." 3028 | ] 3029 | }, 3030 | { 3031 | "cell_type": "markdown", 3032 | "metadata": {}, 3033 | "source": [ 3034 | "There is a lot more to learn about arrays, some of which we will come across as we use Julia in future notebooks. One more thing to learn about `Array` objects is how to do arithmetic operations with them. Addition and subtraction of `Array` objects is done element-wise and the object must therefor have the same dimensions (number of rows and columns). The `Matrix` objects `reshape(1:12, 3, 4)` and `reshape(13:24, 3, 4)` are added together in the code cell below." 3035 | ] 3036 | }, 3037 | { 3038 | "cell_type": "code", 3039 | "execution_count": 110, 3040 | "metadata": {}, 3041 | "outputs": [ 3042 | { 3043 | "data": { 3044 | "text/plain": [ 3045 | "3×4 Matrix{Int64}:\n", 3046 | " 14 20 26 32\n", 3047 | " 16 22 28 34\n", 3048 | " 18 24 30 36" 3049 | ] 3050 | }, 3051 | "metadata": {}, 3052 | "output_type": "display_data" 3053 | } 3054 | ], 3055 | "source": [ 3056 | "# Add the Matrix objects reshape(1:12, 3, 4) and reshape(13:24, 3, 4)\n", 3057 | "reshape(1:12, 3, 4) + reshape(13:24, 3, 4)" 3058 | ] 3059 | }, 3060 | { 3061 | "cell_type": "markdown", 3062 | "metadata": {}, 3063 | "source": [ 3064 | "That was simple enough. What is we want to add a scalar to each element in an `Array` object, though? Below we add $3$ to the `Array` object `[1, 2, 3]`. Our aim is to eadd $3$ toe each element in the `Array` object `[1, 2, 3]`." 3065 | ] 3066 | }, 3067 | { 3068 | "cell_type": "code", 3069 | "execution_count": 115, 3070 | "metadata": {}, 3071 | "outputs": [ 3072 | { 3073 | "data": { 3074 | "text/plain": [ 3075 | "3-element Vector{Int64}:\n", 3076 | " 4\n", 3077 | " 5\n", 3078 | " 6" 3079 | ] 3080 | }, 3081 | "metadata": {}, 3082 | "output_type": "display_data" 3083 | } 3084 | ], 3085 | "source": [ 3086 | "# Add 3 to each element of the Array object [1, 2, 3]\n", 3087 | "[1, 2, 3] .+ 3" 3088 | ] 3089 | }, 3090 | { 3091 | "cell_type": "markdown", 3092 | "metadata": {}, 3093 | "source": [ 3094 | "If you look carefully you will see the `.+` operator. This is a broadcast operator. It is used to apply an operation to each element in an `Array` object. Using the `.` in front of the operator tells Julia to apply the operation to each element in the `Array` object, that is to say, doing element-wise operations. If we did not use the broadcast operator, we would get an error. It makes no sense mathematically to add a scalar and a vector. This is not true when we multiply a scalar and a vector or a matrix in mathematics. Scalar-vector and sclar-matrix multiplication is well defined. Below we multiply the scalar $3$ and the `Array` object `[1, 2, 3]` (representing a mathematical vector). Here, we do not have to use the broadcast operator." 3095 | ] 3096 | }, 3097 | { 3098 | "cell_type": "code", 3099 | "execution_count": 113, 3100 | "metadata": {}, 3101 | "outputs": [ 3102 | { 3103 | "data": { 3104 | "text/plain": [ 3105 | "3-element Vector{Int64}:\n", 3106 | " 3\n", 3107 | " 6\n", 3108 | " 9" 3109 | ] 3110 | }, 3111 | "metadata": {}, 3112 | "output_type": "display_data" 3113 | } 3114 | ], 3115 | "source": [ 3116 | "# Multiply 3 times the Array object [1, 2, 3]\n", 3117 | "3 * [1, 2, 3]" 3118 | ] 3119 | }, 3120 | { 3121 | "cell_type": "markdown", 3122 | "metadata": {}, 3123 | "source": [ 3124 | "Another common example of the use of broadcast operators is when we use conditional. Perhaps we want to know which elements in a vector is larger than a specific scalar. below, we use the `.>` operator to determine which elements in the `Array` object `[1, 2, 3, 4, 5, 6]` are larger than the scalar $2$." 3125 | ] 3126 | }, 3127 | { 3128 | "cell_type": "code", 3129 | "execution_count": 116, 3130 | "metadata": {}, 3131 | "outputs": [ 3132 | { 3133 | "data": { 3134 | "text/plain": [ 3135 | "6-element BitVector:\n", 3136 | " 0\n", 3137 | " 0\n", 3138 | " 1\n", 3139 | " 1\n", 3140 | " 1\n", 3141 | " 1" 3142 | ] 3143 | }, 3144 | "metadata": {}, 3145 | "output_type": "display_data" 3146 | } 3147 | ], 3148 | "source": [ 3149 | "# Determine which elements in the Array object [1, 2, 3, 4, 5, 6] are greater than 2\n", 3150 | "[1, 2, 3, 4, 5, 6] .> 2" 3151 | ] 3152 | }, 3153 | { 3154 | "cell_type": "markdown", 3155 | "metadata": {}, 3156 | "source": [ 3157 | "The result is a `BitVector` object. A `BitVector` object is a vector of Boolean values. The `BitVector` object is `true` where the condition is `true` and `false` where the condition is `false`. We have that `false` is represented as a $0$ and `true` is represented as a $1$." 3158 | ] 3159 | }, 3160 | { 3161 | "cell_type": "markdown", 3162 | "metadata": {}, 3163 | "source": [ 3164 | "### Tuples in Julia" 3165 | ] 3166 | }, 3167 | { 3168 | "cell_type": "markdown", 3169 | "metadata": {}, 3170 | "source": [ 3171 | "We create `Tuple` objects using parentheses `()`. The `Tuple` object `(1, 2, 3)` is shown in the code cell below." 3172 | ] 3173 | }, 3174 | { 3175 | "cell_type": "code", 3176 | "execution_count": 71, 3177 | "metadata": {}, 3178 | "outputs": [ 3179 | { 3180 | "data": { 3181 | "text/plain": [ 3182 | "(1, 2, 3)" 3183 | ] 3184 | }, 3185 | "metadata": {}, 3186 | "output_type": "display_data" 3187 | } 3188 | ], 3189 | "source": [ 3190 | "# Create the Tuple object (1, 2, 3)\n", 3191 | "(1, 2, 3)" 3192 | ] 3193 | }, 3194 | { 3195 | "cell_type": "markdown", 3196 | "metadata": {}, 3197 | "source": [ 3198 | "The `typeof` function confirm the data type of the `Tuple` object `(1, 2, 3)`." 3199 | ] 3200 | }, 3201 | { 3202 | "cell_type": "code", 3203 | "execution_count": 72, 3204 | "metadata": {}, 3205 | "outputs": [ 3206 | { 3207 | "data": { 3208 | "text/plain": [ 3209 | "Tuple{Int64, Int64, Int64}" 3210 | ] 3211 | }, 3212 | "metadata": {}, 3213 | "output_type": "display_data" 3214 | } 3215 | ], 3216 | "source": [ 3217 | "# Determine the type of the Tuple object (1, 2, 3)\n", 3218 | "typeof((1, 2, 3))" 3219 | ] 3220 | }, 3221 | { 3222 | "cell_type": "markdown", 3223 | "metadata": {}, 3224 | "source": [ 3225 | "By now I trust that you have a sense of the type of information that Julia returns when we create an object or when we use the `typeof` function. Explore and learn!" 3226 | ] 3227 | }, 3228 | { 3229 | "cell_type": "markdown", 3230 | "metadata": {}, 3231 | "source": [ 3232 | "`Tuple` objects are different from `Array` objects. `Tuple` objects are immutable. This means that the values in a `Tuple` object cannot be changed. The values in a `Tuple` object can be accessed using square brackets `[]` as with `Array` objects, though. The value at the index $2$ of the `Tuple` object `(10, 20, 30)` is shown in the code cell below." 3233 | ] 3234 | }, 3235 | { 3236 | "cell_type": "code", 3237 | "execution_count": 73, 3238 | "metadata": {}, 3239 | "outputs": [ 3240 | { 3241 | "data": { 3242 | "text/plain": [ 3243 | "20" 3244 | ] 3245 | }, 3246 | "metadata": {}, 3247 | "output_type": "display_data" 3248 | } 3249 | ], 3250 | "source": [ 3251 | "# Determine the value at index 2 in the Tuple object (10, 20, 30)\n", 3252 | "(10, 20, 30)[2]" 3253 | ] 3254 | }, 3255 | { 3256 | "cell_type": "markdown", 3257 | "metadata": {}, 3258 | "source": [ 3259 | "As with an `Array` object, we can also have different data types in a `Tuple` object. The `Tuple` object `(\"Diabetes, 42, 3.14)` is shown in the code cell below." 3260 | ] 3261 | }, 3262 | { 3263 | "cell_type": "code", 3264 | "execution_count": 74, 3265 | "metadata": {}, 3266 | "outputs": [ 3267 | { 3268 | "data": { 3269 | "text/plain": [ 3270 | "(\"Diabetes\", 42, 3.14)" 3271 | ] 3272 | }, 3273 | "metadata": {}, 3274 | "output_type": "display_data" 3275 | } 3276 | ], 3277 | "source": [ 3278 | "# Create a tuple of the elements \"Diabetes\", 42, 3.14\n", 3279 | "(\"Diabetes\", 42, 3.14)" 3280 | ] 3281 | }, 3282 | { 3283 | "cell_type": "markdown", 3284 | "metadata": {}, 3285 | "source": [ 3286 | "### Dictionary objects in Julia" 3287 | ] 3288 | }, 3289 | { 3290 | "cell_type": "markdown", 3291 | "metadata": {}, 3292 | "source": [ 3293 | "A `Dictionary` object in Julia is used to store key-value pairs. We use the `Dict` class to create `Dictionary` objects. The `Dictionary` object `Dict(\"name\" => \"John\", \"age\" => 42, \"pi\" => 3.14)` is shown in the code cell below." 3294 | ] 3295 | }, 3296 | { 3297 | "cell_type": "code", 3298 | "execution_count": 75, 3299 | "metadata": {}, 3300 | "outputs": [ 3301 | { 3302 | "data": { 3303 | "text/plain": [ 3304 | "Dict{String, Any} with 3 entries:\n", 3305 | " \"name\" => \"John\"\n", 3306 | " \"weight\" => 180.5\n", 3307 | " \"age\" => 42" 3308 | ] 3309 | }, 3310 | "metadata": {}, 3311 | "output_type": "display_data" 3312 | } 3313 | ], 3314 | "source": [ 3315 | "# Create a Dictionary obejct with the key-value pairs \"name\" => \"John\", \"age\" => 42, \"weight\" => 180.5\n", 3316 | "Dict(\"name\" => \"John\", \"age\" => 42, \"weight\" => 180.5)" 3317 | ] 3318 | }, 3319 | { 3320 | "cell_type": "markdown", 3321 | "metadata": {}, 3322 | "source": [ 3323 | "The `keys` function returns the keys of a `Dictionary` object. The `keys` function is shown in the code cell below to return the keys of the `Dictionary` object `Dict(\"name\" => \"John\", \"age\" => 42, \"pi\" => 3.14)`." 3324 | ] 3325 | }, 3326 | { 3327 | "cell_type": "code", 3328 | "execution_count": 76, 3329 | "metadata": {}, 3330 | "outputs": [ 3331 | { 3332 | "data": { 3333 | "text/plain": [ 3334 | "KeySet for a Dict{String, Any} with 3 entries. Keys:\n", 3335 | " \"name\"\n", 3336 | " \"weight\"\n", 3337 | " \"age\"" 3338 | ] 3339 | }, 3340 | "metadata": {}, 3341 | "output_type": "display_data" 3342 | } 3343 | ], 3344 | "source": [ 3345 | "# Determine the keys in the Dictionary Dict(\"name\" => \"John\", \"age\" => 42, \"weight\" => 180.5)\n", 3346 | "keys(Dict(\"name\" => \"John\", \"age\" => 42, \"weight\" => 180.5))" 3347 | ] 3348 | }, 3349 | { 3350 | "cell_type": "markdown", 3351 | "metadata": {}, 3352 | "source": [ 3353 | "The `values` function can be used to determine the values in a dictionary object." 3354 | ] 3355 | }, 3356 | { 3357 | "cell_type": "code", 3358 | "execution_count": 77, 3359 | "metadata": {}, 3360 | "outputs": [ 3361 | { 3362 | "data": { 3363 | "text/plain": [ 3364 | "ValueIterator for a Dict{String, Any} with 3 entries. Values:\n", 3365 | " \"John\"\n", 3366 | " 180.5\n", 3367 | " 42" 3368 | ] 3369 | }, 3370 | "metadata": {}, 3371 | "output_type": "display_data" 3372 | } 3373 | ], 3374 | "source": [ 3375 | "# Determine the values in the Dictionary Dict(\"name\" => \"John\", \"age\" => 42, \"weight\" => 180.5)\n", 3376 | "values(Dict(\"name\" => \"John\", \"age\" => 42, \"weight\" => 180.5))" 3377 | ] 3378 | }, 3379 | { 3380 | "cell_type": "markdown", 3381 | "metadata": {}, 3382 | "source": [ 3383 | "Indexing can also be used with `Dictionary` objects. Here we acturally pass the name of the key inside the square brackets to get the value." 3384 | ] 3385 | }, 3386 | { 3387 | "cell_type": "code", 3388 | "execution_count": 78, 3389 | "metadata": {}, 3390 | "outputs": [ 3391 | { 3392 | "data": { 3393 | "text/plain": [ 3394 | "\"John\"" 3395 | ] 3396 | }, 3397 | "metadata": {}, 3398 | "output_type": "display_data" 3399 | } 3400 | ], 3401 | "source": [ 3402 | "# Determine the value of the key \"name\" in the Dictionary Dict(\"name\" => \"John\", \"age\" => 42, \"weight\" => 180.5)\n", 3403 | "Dict(\"name\" => \"John\", \"age\" => 42, \"weight\" => 180.5)[\"name\"]" 3404 | ] 3405 | }, 3406 | { 3407 | "cell_type": "markdown", 3408 | "metadata": {}, 3409 | "source": [ 3410 | "## Importing packages in Julia" 3411 | ] 3412 | }, 3413 | { 3414 | "cell_type": "markdown", 3415 | "metadata": {}, 3416 | "source": [ 3417 | "By know we would all agree that Julia is a powerful language indeed. But, it is not perfect. There are many things that we would like to do that Julia does not support out of the box. This is where packages come in. Packages are collections of functions that can be used to extend the functionality of Julia. We can import packages using the `using` keyword. The `using` keyword is followed by the name of the package." 3418 | ] 3419 | }, 3420 | { 3421 | "cell_type": "markdown", 3422 | "metadata": {}, 3423 | "source": [ 3424 | "Some packages are a part of the Julia language, but their functionality is not available when starting up Julia. These include the 'Statistics` and `Random` packages. We import these packages in the code cell below." 3425 | ] 3426 | }, 3427 | { 3428 | "cell_type": "code", 3429 | "execution_count": 1, 3430 | "metadata": {}, 3431 | "outputs": [], 3432 | "source": [ 3433 | "# Import the Statistics and the Random modules\n", 3434 | "using Statistics\n", 3435 | "using Random" 3436 | ] 3437 | }, 3438 | { 3439 | "cell_type": "markdown", 3440 | "metadata": {}, 3441 | "source": [ 3442 | "The `Random` package is used to generate random values. The randomness is only pseudo-random, as an algorithm is used to generate the values. There are many such algorithms and Julia uses uses the `Xoshiro256++` algorithm by default at this time. We refer to the algorithms as random number generators (RNG) or simply generators." 3443 | ] 3444 | }, 3445 | { 3446 | "cell_type": "markdown", 3447 | "metadata": {}, 3448 | "source": [ 3449 | "Each time we generate random values we do get different results. This is good in real life, but not so good when learning. Here the emphasis might be on reprodicubility. We want the same _random_ values every time we run the code so that we can all discuss the same results. As the generators are algorithms, we can seed the algorith with a specific number. The `seed!` function is used to set the seed of the random number generator. The `seed!` function is shown in the code cell below to set the seed of the random number generator to $42$. We the use the `randexp` function (with parameter $1$) from the `Random` package to generate a random number from the exponential distribution." 3450 | ] 3451 | }, 3452 | { 3453 | "cell_type": "markdown", 3454 | "metadata": {}, 3455 | "source": [ 3456 | "Using the code below, we will always get the same random number." 3457 | ] 3458 | }, 3459 | { 3460 | "cell_type": "code", 3461 | "execution_count": 8, 3462 | "metadata": {}, 3463 | "outputs": [ 3464 | { 3465 | "data": { 3466 | "text/plain": [ 3467 | "1-element Vector{Float64}:\n", 3468 | " 1.4515762558532885" 3469 | ] 3470 | }, 3471 | "metadata": {}, 3472 | "output_type": "display_data" 3473 | } 3474 | ], 3475 | "source": [ 3476 | "# Seed the pseudo-random number generator with the integer 42\n", 3477 | "Random.seed!(42)\n", 3478 | "\n", 3479 | "# Generate a random number\n", 3480 | "Random.randexp(1)" 3481 | ] 3482 | }, 3483 | { 3484 | "cell_type": "markdown", 3485 | "metadata": {}, 3486 | "source": [ 3487 | "Note that we used the name of the package with a dot and then the name of the function. This is because the function is part of the package. The `randexp` function is part of the `Random` package. Depending on how a package is designed, we might have to use this syntax. It is more common, though, that a package is designed so that once imported, the functions can be used without the package name. This is not so for the `seed` function, but is true for the `randexp` function." 3488 | ] 3489 | }, 3490 | { 3491 | "cell_type": "code", 3492 | "execution_count": 10, 3493 | "metadata": {}, 3494 | "outputs": [ 3495 | { 3496 | "data": { 3497 | "text/plain": [ 3498 | "1-element Vector{Float64}:\n", 3499 | " 1.4515762558532885" 3500 | ] 3501 | }, 3502 | "metadata": {}, 3503 | "output_type": "display_data" 3504 | } 3505 | ], 3506 | "source": [ 3507 | "# Seed the pseudo-random number generator with the integer 42\n", 3508 | "Random.seed!(42)\n", 3509 | "\n", 3510 | "# Generate a random number but don't use the package name\n", 3511 | "randexp(1)" 3512 | ] 3513 | }, 3514 | { 3515 | "cell_type": "markdown", 3516 | "metadata": {}, 3517 | "source": [ 3518 | "It is perhaps a good idea to use the package name syntax when exploring a new package. This way we know where the function comes from. Once we are familiar with the package, we can drop the package name if possible." 3519 | ] 3520 | }, 3521 | { 3522 | "cell_type": "markdown", 3523 | "metadata": {}, 3524 | "source": [ 3525 | "As an aside, we can always assign the RNG to a variable and use the variable to generate random numbers. This is useful when we want to use the same RNG in different parts of the code. We see this in the code cell below." 3526 | ] 3527 | }, 3528 | { 3529 | "cell_type": "code", 3530 | "execution_count": 14, 3531 | "metadata": {}, 3532 | "outputs": [ 3533 | { 3534 | "data": { 3535 | "text/plain": [ 3536 | "1-element Vector{Float64}:\n", 3537 | " 1.4515762558532885" 3538 | ] 3539 | }, 3540 | "metadata": {}, 3541 | "output_type": "display_data" 3542 | } 3543 | ], 3544 | "source": [ 3545 | "# Set the RNG to use the Xoshiro 256++ algorithm with seed 42\n", 3546 | "# Assign the result to the variable \"rng\"\n", 3547 | "rng = Xoshiro(42)\n", 3548 | "\n", 3549 | "# Generate a random number using the Xoshiro 256++ algorithm\n", 3550 | "randexp(rng, 1)" 3551 | ] 3552 | }, 3553 | { 3554 | "cell_type": "markdown", 3555 | "metadata": {}, 3556 | "source": [ 3557 | "The `Random` package works very well in conjunction with the `Distributions` package. The latter is extrnal to Julia and must be installed before it can be imported. The `Distributions` package is used to generate random numbers from different probability distributions. The `Distributions` package is imported in the code cell below." 3558 | ] 3559 | }, 3560 | { 3561 | "cell_type": "code", 3562 | "execution_count": 15, 3563 | "metadata": {}, 3564 | "outputs": [], 3565 | "source": [ 3566 | "# Import the Distributions package\n", 3567 | "using Distributions" 3568 | ] 3569 | }, 3570 | { 3571 | "cell_type": "markdown", 3572 | "metadata": {}, 3573 | "source": [ 3574 | "We can now generate random numbers from different probability distributions. The `Normal` function is used to generate random numbers from a normal distribution If no arguemnts are passed to the `Normal` function, the mean is $0$ and the standard deviation is $1$ (the standard normal distribution). We generate $10$ random numbers from a normal distribution in the code cell below. The result is a `Vector` object that wer assign to the variable `data`." 3575 | ] 3576 | }, 3577 | { 3578 | "cell_type": "code", 3579 | "execution_count": 16, 3580 | "metadata": {}, 3581 | "outputs": [ 3582 | { 3583 | "data": { 3584 | "text/plain": [ 3585 | "10-element Vector{Float64}:\n", 3586 | " 0.2517372155742292\n", 3587 | " -0.31498797116895605\n", 3588 | " -0.31125240132442067\n", 3589 | " 0.8163067649323273\n", 3590 | " 0.47673837983187795\n", 3591 | " -0.8595553820616212\n", 3592 | " -1.4692882055065464\n", 3593 | " -1.6291486488712725\n", 3594 | " -0.31074387308373413\n", 3595 | " -0.040473400248354906" 3596 | ] 3597 | }, 3598 | "metadata": {}, 3599 | "output_type": "display_data" 3600 | } 3601 | ], 3602 | "source": [ 3603 | "# Generate 10 random numbers from the standard normal distribution\n", 3604 | "# Assign the result to the variable \"data\"\n", 3605 | "# Use the \"rng\" RNG\n", 3606 | "data = rand(rng, Normal(), 10)" 3607 | ] 3608 | }, 3609 | { 3610 | "cell_type": "markdown", 3611 | "metadata": {}, 3612 | "source": [ 3613 | "We see a `Vector` object with $10$ elements (observations)." 3614 | ] 3615 | }, 3616 | { 3617 | "cell_type": "markdown", 3618 | "metadata": {}, 3619 | "source": [ 3620 | "Now that we have data, we might want to summarize it. The `Statistics` package is used to perform statistical calculations. The `Statistics` package is imported in the code cell below." 3621 | ] 3622 | }, 3623 | { 3624 | "cell_type": "code", 3625 | "execution_count": 17, 3626 | "metadata": {}, 3627 | "outputs": [], 3628 | "source": [ 3629 | "# Import the Statistics package\n", 3630 | "using Statistics" 3631 | ] 3632 | }, 3633 | { 3634 | "cell_type": "markdown", 3635 | "metadata": {}, 3636 | "source": [ 3637 | "The `Statistics` package has many functions that can be used to summarize data. The `mean` function is used to determine the mean of the data. The `mean` function is shown in the code cell below to determine the mean of the `Vector` object `data`." 3638 | ] 3639 | }, 3640 | { 3641 | "cell_type": "code", 3642 | "execution_count": 18, 3643 | "metadata": {}, 3644 | "outputs": [ 3645 | { 3646 | "data": { 3647 | "text/plain": [ 3648 | "-0.33906675219264715" 3649 | ] 3650 | }, 3651 | "metadata": {}, 3652 | "output_type": "display_data" 3653 | } 3654 | ], 3655 | "source": [ 3656 | "# Calculate the mean of the observations in the \"data\" variable\n", 3657 | "Statistics.mean(data)" 3658 | ] 3659 | }, 3660 | { 3661 | "cell_type": "markdown", 3662 | "metadata": {}, 3663 | "source": [] 3664 | } 3665 | ], 3666 | "metadata": { 3667 | "kernelspec": { 3668 | "display_name": "Julia 1.11.3", 3669 | "language": "julia", 3670 | "name": "julia-1.11" 3671 | }, 3672 | "language_info": { 3673 | "file_extension": ".jl", 3674 | "mimetype": "application/julia", 3675 | "name": "julia", 3676 | "version": "1.11.3" 3677 | } 3678 | }, 3679 | "nbformat": 4, 3680 | "nbformat_minor": 2 3681 | } 3682 | --------------------------------------------------------------------------------