@@ -1146,6 +1146,7 @@ the graphs will actually be squeezed together more closely.)
11461146>difference along a specified axis.
11471147>
11481148>Which axis would it make sense to use this function along?
1149+ >
11491150> > ## Solution
11501151> > Since the row axis (0) is patients, it does not make sense to get the
11511152> > difference between two arbitrary patients. The column axis (1) is in
@@ -1158,23 +1159,27 @@ the graphs will actually be squeezed together more closely.)
11581159> > {: .python}
11591160> {: .solution}
11601161>
1161- >If the shape of an individual data file is `(60, 40)` (60 rows and 40 columns)
1162- >, what would the shape of the array be after you run the `diff()` function and
1163- >why?
1162+ >If the shape of an individual data file is `(60, 40)` (60 rows and 40
1163+ >columns), what would the shape of the array be after you run the `diff()`
1164+ >function and why?
1165+ >
11641166> > ## Solution
11651167> > The shape will be `(60, 39)` because there is one fewer difference between
11661168> > columns than there are columns in the data.
11671169> {: .solution}
11681170>
11691171>How would you find the largest change in inflammation for each patient? Does
11701172>it matter if the change in inflammation is an increase or a decrease?
1173+ >
11711174> > ## Solution
1172- > > By using the `max()` function after you apply the `diff()` function, you
1173- > > will get the largest difference between days.
1175+ > > By using the `numpy.max()` function after you apply the `numpy.diff()`
1176+ > > function, you will get the largest difference between days.
1177+ > >
11741178> > ~~~
1175- > > numpy.diff(data, axis=1).max( axis=1)
1179+ > > numpy.max(numpy. diff(data, axis=1), axis=1)
11761180> > ~~~
11771181> > {: .python}
1182+ > >
11781183> > ~~~
11791184> > array([ 7., 12., 11., 10., 11., 13., 10., 8., 10., 10., 7.,
11801185> > 7., 13., 7., 10., 10., 8., 10., 9., 10., 13., 7.,
@@ -1184,16 +1189,19 @@ the graphs will actually be squeezed together more closely.)
11841189> > 8., 12., 10., 7., 12.])
11851190> > ~~~
11861191> > {: .python}
1192+ > >
11871193> > If a difference is a *decrease*, then the difference will be negative. If
11881194> > you are interested in the **magnitude** of the change and not just the
11891195> > direction, the `numpy.absolute()` function will provide that.
11901196> >
11911197> > Notice the difference if you get the largest _absolute_ difference
11921198> > between readings.
1199+ > >
11931200> > ~~~
1194- > > numpy.absolute(numpy.diff(data, axis=1)).max( axis=1)
1201+ > > numpy.max(numpy. absolute(numpy.diff(data, axis=1)), axis=1)
11951202> > ~~~
11961203> > {: .python}
1204+ > >
11971205> > ~~~
11981206> > array([ 12., 14., 11., 13., 11., 13., 10., 12., 10., 10., 10.,
11991207> > 12., 13., 10., 11., 10., 12., 13., 9., 10., 13., 9.,
@@ -1203,5 +1211,6 @@ the graphs will actually be squeezed together more closely.)
12031211> > 11., 13., 10., 10., 12.])
12041212> > ~~~
12051213> > {: .python}
1214+ > >
12061215> {: .solution}
12071216{: .challenge}
0 commit comments