# Explaining why arrays are important for statisticians

I am a computer engineer, and I’m teaching computer sciences one hour per week to a student who failed her second-year university degree. She needed some help to have a better understanding of programming, and increase her grade in this field. Computer science is not the main subject of her degree which is based on maths and physics.

I asked her if she wanted to emphasise on a difficult subject for her, or if I should start from scratch and explain programming as if it was totally new for her. She chose the second solution, so I started to explain her the base of programming, binary, variables, functions, conditional statements, loops. And now I emphasis on the most common data structure ever, the array.

I teach her how to use an array, manipulate its element, etc... As she had to use programming to solve problems of graph theory, physics measurements, and mathematical algorithms which use a lot of matrices and arrays, I spend about six hours to make her be more familiar with it.

I simplified it to make her use one-dimensional arrays with a simple algorithm, and she just told me that she can’t understand how arrays will be of any use for her, for her everyday life. She aims to get job in the field of statistics.

I explained to her, that she uses array everyday without thinking about it. For example when you log in a website, there’s somewhere an array (or an object) which stores your username, password, email, and compares it to what is stored in a database. But she didn’t feel very enthusiastic.

So I can understand that not everybody enjoys programming, and as I am not a statistician I can’t really tell her about how useful this can be for a statistician.

What can I do to actually make her change her mind about programming or show her the use of it for a statistician ?

EDIT: I work as Web developper so I am not used to statistics. I can't think about useful example or exercise to show her the usage of arrays in statistics.

EDIT: She already saw by herself that was I taugh her about arrays is usefull in various situation. She saw that know, as she understood arrays, she can now solve problems she wasn't able to solve before.

• It depends how much she knows about statistics? If she is basic in statistic you could describe the importance of arrays by describing how you could store the values of a probability distribution function numerically in an array or something similar to this example. But if she knows about advanced statistical analysis (e.g. machine learning) you could give her some more advanced examples. – Alone Programmer Oct 18 '18 at 22:10
• Oh I Didn't know about CSEducators, I will try to post there too. @AloneProgrammer It's a little more complicated, the student is in a 2 year formation to integrate a 3 year formation ( French academic system). After this 5 cumulated years she will have the equivalent of a master degree. So at this moment, she only knows about basic statistics – Med Oct 19 '18 at 6:45
• Surely she must understand the value of being able to store a data series, and calculate its properties? Something as simple as calculating the mean might be a useful first step. – Anyon Oct 19 '18 at 17:20
• Maybe it's too simple and she need something more difficult, to see how computing is a good way to solve the problem. That's what I'm wondering because I taugh the basics ( find max/min, count how many times the value 'x' is in the list, how many elements verify a condition, etc...) in order to make her more at ease manipulating datas. Maybe it's because I didn't link it to some sort of mathematical problem that she can't see about the use of lists/arrays... – Med Oct 19 '18 at 22:36
• Re, "...there’s somewhere an array (or an object) which stores your username, password,..." IMO, there's quite a difference between how you use an array (members are addressed by numeric index, all have the same type), and an object (members accessed by name, non-homogeneous types.) – Solomon Slow Oct 24 '18 at 20:52

Try to let her model a questionaire and aswers from different people. Ask her how she would organize the data on a sheet of paper. Let her do so for

• one questionaire filled in by one person
• question 1 (e.g. "your age") for all questionaires
• all questions for all questionaires

This should result in two 1d-arrays (and bring up the topic of data types, lists can be a solution) and one 2d-array.

Those data representations are quite common in statistics, based on those you can e.g. calculate the median, standard deviation, min, max, ...

If you are using a language with an simple interface to gnuplot (like python and mathplolib), you can easily visualize array contents using box plots, scatter plots, etc. This is a direct link to statistics. It is simple to copy-paste example and adapt code from the tutorials, so even a beginner can have nice visual results.

• Simple, but exactly what i was looking for – Med Nov 12 '18 at 9:16

If you are tutoring her, it is wonderful that you are trying to motivate the material in a practical way, but don't beat yourself up too much if you aren't that successful at persuading her. Some people just get themselves into a sort of myopic headspace where the only things that they need to learn are the exact operations that they will perform later on in their life.

However, it has been my experience that there is often something else going on in these situations. People aren't creating these excuses because of what will be practical in the future. They have no idea what the future holds. They actually create these utilitarian excuses simply because they don't find the topic intrinsically fun yet.

This also explains why you make no headway when you show her the utilitarian benefits; they aren't truly what is preventing her from diving in. Your best bet, then, is to show her why you think this whole field is amazing.

And if all else fails, go back to a utilitarian approach, but stick to the most direct reason: she needs this so that she will pass her class next semester. That was a strong enough motivation for her to meet with you in the first place, so it should work out well enough to at least get you through the lessons.

Good luck!

• Maybe in the next lessons, as we have finished to learn lists basic, nex step is to take a big problem and split it in simplier problems which she know how to solve, divide and conquer ;) I plan to make her code a little tic tac toe game which can be a more fun way to manipulate lists. – Med Oct 19 '18 at 22:54

Have you tried a simple statistics formula such as $$mean = \left(\sum_{i=1}^{n} x_i\right) / n$$ This maps exactly to array notation. Explain that the array x refers to the entire set of values and that x[i] refers to a single element in the set. Then show a simple loop that performs the computation.

• I will try this – Med Oct 23 '18 at 22:11

I had a student some time back who also really struggled with concepts like this, but who was interested in research in psychology which for her was largely about statistics.

Statistical data is nothing but arrays, or perhaps tables, that is, 2-dimensional arrays. Statisticians conduct trials consisting of observations. An observation is a simultaneous measurement of some variables. The numeric ("quantitative") variables are distinguished from "categorical" variables that assume values in a prescribed finite set. Anyway, the variables typically go across the columns and the observations go down the rows of the table. The R programming language/environment is based entirely on arrays for this reason and many of its most important statistical functions are optimized to work on "columns" of a table: that is, arrays.

I would explain to your student how the vast majority of statistical observation is in fact naturally in array form. If she has any spreadsheets to show you you can find many examples of arrays in her data and show how the calculations she has already done to analyze them are in fact array-based calculations as suggested in another answer with means. An array-based language like R, but really any language, will lend itself to some calculations that can be a real pain to do in something like Excel. Find those examples and I think you will have made some progress.

Arrays are like dressers: they allow you to organize a collection of objects and store them in a single place. A dataset in stat should be seen as an array of results (numbers, vectors, etc.). The array object is provided with a nice array of methods for searching itself, inserting items, and and for item access.

It shouldn't be so difficult to come to a point where she really wants to use arrays. Just ask her what she has done so far in the mathematics/physics part of her degree. I am 100% sure that there will be something for which she needed linear algebra to solve it. Decoupling of harmonic oscillators for example, or just any eigenvalue problem in quantum mechanics. Then ask her to write a program which does these calculations without using arrays. Make it big enough. $$10\times 10$$-matrices should do the job. If she doesn't give up after declaring 100 variables with distinct names, then she will definitely give up at the first instance of matrix multiplication, when she realizes, that she can't loop over those 100 names and that she has to write out every arithmetic operation one by one.

So these are two different questions. To show her how important arrays are compared to for example lists you could use a metaphor like a book. If you want to find page 831 with a list you need to look at every single page before that. With an array you just jump to page 831 which is a lot faster. In the future she will work with big chunks of data. This means she has to be efficient. Arrays are the way to achieve it.

The second part why programming is important. You could ask people who already work in the industry to give you day to day tasks they have to deal with and show her this way that if she works in this field she will use programming a lot. From my experience people who work in statistics are always happy to help people who are interested in there work.

Also it is important to remember that a company will choose someone with coding experience if they have the same qualifications otherwise.

• Welcome to CSEd! That's a nice first post :) – Ben I. Oct 19 '18 at 19:07
• Good point about coding experience will help her find a job. It's true, but I would like to show her that's it a real plus for her everyday life at her futur job. – Med Oct 19 '18 at 22:50

In statistics you deal with possibly large sets of data. Sometimes you need all of the data available at once for some sort of processing. Arrays are helpful for this. Sometimes you need to sort the data. Again, arrays can be helpful, as can binary trees.

Finding the median of a set of values is interesting. Initially it sounds like it is a sorting problem, but it is a bit more subtle than that. But arrays are still useful.

Lists, by the way, which are similar to arrays in some ways, are possibly even more fundamental.

But some things are worth studying for no other reason than that they help you expand your mental facilities. Studying things somewhat on the periphery of your main interest can help you, potentially, in that main line study. Programming is like that for statistics, as is mathematics in general. When you learn things you generally increase your potential for learning other things.

• She is at an age where she can't really see how important it is to have general knowledge. – Med Oct 19 '18 at 22:53
• I would think second year university is old enough, actually. Perhaps she is too focused, generally. – Buffy Oct 19 '18 at 22:55
• It's french system known as CPGE ( Classes Préparatoires aux Grandes Ecoles) with a lot of maths and physics, a few computer science, and a LOT of pressure. As computer science is not seen as a prerequisite or important subject for her, that maybe why she can't see why I focus so much on making her being at ease with lists/arrays – Med Oct 19 '18 at 22:59