A home-lab to study uncertainties using smartphone sensors and determine the optimal number of measurements

. We present a home-lab experimental activity, successfully proposed to our students during covid19 pandemic, based on state-of-the-art technologies to teach error analysis and uncertainties to science and engineering students. In the last decade the appearance of smartphones considerably affected our daily life. Thanks to their built-in sensors, this revolution has impacted in many areas and, in particular, the educational field. Here we show how to use smartphone sensors to teach fundamental concepts for science students such as any measurement is useless unless a confidence interval is specified or how to determine if a result agrees with a model, or to discern a new phenomenon from others already known. We explain how to obtain and analyse experimental fluctuations and discuss in relation with the Gaussian distribution. In another application we show how to determine the optimal number of measurements as a function of the standard error and the digital resolution of a given sensor.


Introduction
Statistical analysis is usually introduced in introductory laboratory courses in first years of science studies [1,2].The typical approaches are based on performing manually repetitive observations, for example, measuring a time interval with a stopwatch under identical conditions.This kind of measurement gives slightly different results due to the fact in the real world there exist statistical fluctuations.The measurements obtained are usually examined from the statistical viewpoint plotting histograms, calculating mean values and standard deviations and, eventually, compared with those expected from a known distribution, typically a normal distribution.Commonly these experiments are tedious and require a lot of time to be able to perform an adequate number of measurements to perform the statistical analysis (see for example the classical experiments proposed in Refs.[3,4]).
The use of smartphone sensors has been incorporated in Physics laboratories in all the fields, see for example [5,6,7].Worth mentioning characteristics of modern smartphones are the ability to measure simultaneously with more than one sensor [8] or supplement the data with video analysis [9].A very important advantage is that students usually have smartphones and can therefore conduct experiments at home (see for example [10,11,12]).In almost all the experiments, the focus is on the mean values reported by the sensors while the fluctuations play an annoying role.Recently, it has been proposed a novel approach to study uncertainties and errors in Physics laboratories taking the advantages provides by smartphone sensors [13].In this work, based on data recorded with the sensors present in many mobile devices, we propose a set of experiments that can be performed at home to teach error and uncertainties.In particular we discuss the role of the digital resolution of the sensors and how to relate this quantify to the statistical magnitudes to determine the optimal number of repetitive measurements.

A first approach to deal with statistics
In this work we focus on the teaching of statistical uncertainties which due to a multitude of causes are inherent to all physical measurements [1].We assume that in a given experiment an observation is repeated N times under identical conditions obtaining different results x i , with i = 1, .., N .It can be shown that the best representative or estimate of the set of values is given by the mean value x defined as The deviation with respect to the mean value is identified with ϵ i = x i − x.It can be shown that the mean value defined as above minimizes the sum of the squared deviations.Intuitively, it can be regarded as the center-of-mass of the set of the observations or equivalent to the value closest to all the other values.In statistical uncertainties it is of interest to quantify the dispersion of the values around the mean value or, informally, the width of the cloud.The standard deviation defined as can be seen as a measure of this dispersion.If the number of observations, N , is large enough, σ it is characteristic of the set of all the possible observations and does not depend on the specific set of observations.In practice, the uncertainty in the determination of a physical magnitude depends on the number of repeated measurements we have done.
The standard deviation, if N is large enough, is characteristic of the set of all the possible observations whereas the standard error, or standard deviation of the mean, defined as represents the margin of uncertainty of the mean value obtained in a particular set of measurements [1].The result of a specific measurement is usually expressed as a z ± σ( āz ) representing the best estimate and 68% confidence in that value.
It is worth highlighting that the standard deviation is related to the degree to which an observation deviated from the mean value whereas the standard error is an estimate of the uncertainty of the mean value.In a practical situation the standard uncertainty depends on the number of measurements taken with N −1/2 .Then, given a set of N measures the standard deviation gives an idea of the dispersion of an ideal set of infinite measures while the standard uncertainty represents the uncertainty of our particular set of measurements.This uncertainty can be reduced by increasing the number of measurements, however, the square-root implies that this reduction is relatively slow.

Errors and uncertainties using smartphone sensors
Mobile devices such as smartphones or tablets include several sensors (accelerometer, magnetometer, ambient light sensor, among others) that can be used as an alternative proposal to deal with statistical distributions.The unavoidable fluctuations present in the several sensors, so annoying in any measurement, can be used, however, favourably, to illustrate basic concepts of statistical treatment of errors and uncertainties [13].Using these sensors, it is possible to acquire hundreds or thousands of repeated measurements of a physical magnitude in a few seconds and analyse them in the mobile device or transferred to a personal computer or analysed in the cloud.
To access data registered by the sensors it is necessary to use an special piece of software, or app.There are many suitable options available in the digital stores.In this proposal we mainly use the Phyphox app [14] which stands out because of its friendly interface and the possibility to access to experiments programmed or proposed by other users.As an example we show in Fig. 1 the statistics of the vertical component of the accelerometer value while the smartphone is simply resting on a table.The graph on the top is the temporal evolution of the values during an interval of about 20 s.We can observe that the values oscillate around the gravitational acceleration value.The corresponding histogram is plotted on the bottom panel where a Gaussian fit is overlapped.Mean value, standard deviation, bin size and number of measurements are also indicated on the bottom.
As mentioned before, sensor data can be analysed in the smartphone or transferred to a computer.Next, we show in Fig. 2 the temporal evolution of the vertical acceleration (top panel).We also included in this graph horizontal lines at values x ± σ, x ± 2σ and x ± 3σ.These interval can be used to count the number of values in each interval and compare with the well-known expected percentages according to a Gaussian distribution.In the bottom panel we show the histogram and the corresponding Gaussian fit using the mean value and standard deviation of the experimental data.
An interesting point is to consider, taking advantage of the capability to quickly register data, different number of repetitive measurements N for the same experimental setup.In Table .1 we report results of the mean value, standard deviation and standard error for different length of these experimental series.This information is also plotted in Fig. 3 where we show the standard uncertainty as a function of N .As mentioned above, it is clear from that data that σ az is nearly constant and, as a consequence, σ( āz ) is proportional to N −1/2 .According to our experience, this graph results more convincing to the students than theoretical explanations.

Digital resolution and optimal number of measurements
A closer look at the temporal evolution of the accelerometer data reveals that the distribution in the vertical axis is not continuous but instead present discrete values separated by uniform intervals.The minimum interval corresponds to the digital resolution of the sensor.In Fig. 5 we present a zoom of the z component of the acceleration in which we can better appreciate the discrete distribution.The digital resolution can be estimate from this graph to be of the order of 10 −3 m/s 2 .
The choice of N in a specific experiment is a delicate question.Indeed, if we could repeat the measurements infinite times the standard uncertainty would vanish and we could achieve a perfect knowledge of the best estimate.However, as the decrease of the standard uncertainty with the number of observations is slow, it is impractical to increment this number excessively.A common criterion is to take a number of measurements, often referred as the optimal N x σ σ x 563 9,493 0,020 0,00085 1156 9,487 0,019 0,00054 1746 9,478 0,018 0,00044 2348 9,469 0,019 0,00039 2941 9,466 0,020 0,00036 3535 9,464 0,019 0,00032 4166 9,462 0,019 0,00029 4733 9,464 0,019 0,00027 5327 9,465 0,019 0,00026 5919 9,464 0,020 0,00026 Table 1.Mean value, standard deviation and standard error as a function of the number of measurements corresponding to several experiments under identical conditions.Figure 3. Standard error as a function of the number of repetitive measurements.We notice that the standard uncertainty slowly decreases as we increase N .number of measurements, N opt , such that the statistical uncertainty is of the same order as the systematic (or type B) errors.Here, in the absence of other sources of systematic errors, the standard uncertainty should be of the same order as the resolution of the digital instrument: σ( āz ) = σ az / N opt ∼ δ.In the experiment depicted in Table 1 with a LG G3, the resolution is δ = 0.0012 m/s 2 , therefore N opt ∼ 250.It is worth emphasizing that this estimate is optimistic and must be examined in case of having other sources of systematic errors.

Other applications
This set of activities is just a sample of all that can be done by linking sensors and statistical fluctuations.It is possible to consider variations of the mean values or of the standard deviation or width of the distributions [13].This quantity is linked to the intensity of the fluctuations.As possible applications we can mention proposing a challenge to the students to take the picture or selfie with the lowest level of fluctuations.Another application would be to evaluate the comfort of a means of transport, car, bus, plane or even the state of a traffic road [15].Another experiment (not recommended by the authors) is to study the fluctuations of the gait of a pedestrian as a function of the alcohol beverage intake, similarly to Ref. [16].It is also possible to analyse the statistical character of other magnitudes different from the acceleration.To show another possibility, Fig. 6 reproduces a screenshot of a similar experiment using, in this case, the magnetometer.This analysis can be useful when considering outdoor experiments dealing with magnetic field as proposed in Ref. [17].

Closing remarks
The COVID19 pandemic strongly affected experimental activities in introductory physics courses almost everywhere in the world.This forced us to reformulate traditional instructional laboratories to make it possible to conduct them in students' homes or even outdoors.As a positive by-product of these restrictions we proposed this home laboratory to experiment with statistical errors and uncertainties and involves fundamental concepts related such as mean values, standard distributions, histograms and fluctuations.The main tool used are the built-in sensors embedded in smartphones that are widely available to students.These devices allow to obtain in a few minutes an important number of repetitive measurements.In this work we focus precisely on determining the optimal number of these measurements and link it to the digital resolution of the sensors.Before that, the introductory laboratory to statistical analysis was carried out by means of repetitive measurements.
The evaluation of this activity has been very positive and we can mention some didactic advantages that we have been able to appreciate.On the one hand, the activity can be carried out in an agile way, without waiting times and with the possibility of having the results immediately.These aspects make it possible to allocate more time to the discussion of the relevant aspects.We have found that this clearly helps students gain a significant understanding of the physical meaning of histograms, standard deviation, and other statistical tools.Another notable advantage that we have appreciated is that the use of their own devices increases the autonomy of the students, who can apply what they have learned in various situations outside  the laboratory and of which we have taken advantage by inviting the students to observe what happens when they are traveling by car or bus.Finally, we can mention that in general we have been able to notice that the students show more interest and commitment when carrying out these activities with the sensors than when we carried out the traditional laboratory.These experiments could contribute to motivating students and showing them the necessity of considering uncertainty analysis.Several possible extensions related to non-normal statistics can be considered, such as Poisson distribution [4], distribution of maxima, Chauvenet criterion [18], or Benford's law [19].

Figure 1 .
Figure 1.Phyphox screenshot of the vertical component of the accelerometer while the smartphone is resting on a table.

Figure 2 .
Figure 2. Measurements of z acceleration as a function of time for the smartphone held on the hand (top panel) and the histogram with a Gaussian fit (bottom panel).

Figure 4 .
Figure 4. Phyphox screenshots for different values of N .We observe as the number of repetitive measurements is increased the histograms curve results closer to the expected Gaussian fit.

Figure 5 .
Figure 5.A zoom of the temporal evolution of the z component of the acceleration where we can observe the discrete nature of the values reported by the sensor.

Figure 6 .
Figure 6.Phyphox screenshot showing an histogram and the Gaussian fit of the magnetometer data.Note that this data set in considerable noisier than that obtained with the accelerometer.