Exercise: Tiling for array creation
Skim through the documentation for
np.tile, and use this function to construct the array:
[[4, 3, 4, 3, 4, 3], [2, 1, 2, 1, 2, 1], [4, 3, 4, 3, 4, 3], [2, 1, 2, 1, 2, 1]]
|# clean up kernel|
|# This is a bit of magic to make matplotlib figures appear inline in the notebook|
|# rather than in a new window.|
|# Some more magic so that the notebook will reload external python modules;|
|# see http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython|
['hello', 'world', '123', '!!!']
hello world 123 !!!
In Octave, the string manipulation function
strtok() can be very handy for scanning through words in a long sentence.
In the following example, we have a sentence:
'hello world how are you'
Assuming all words are separated by a white space, we can repeat this command to extract (1) the word string
tok and the remaining sentence
Whilst working through the many (Octave) coding assignment from Andrew Ng's Stanford Machine Learning course, a common problem that I have to solve revolves around this:
Given a Matrix A with m rows, and n columns find the mininum (or maximum) value and the associated row and column number
This article summarises my solution to this problem (which, hopefully this will also come in hadny to you!). Note that Octave index start from 1 (instead of 0).
Say we have a Matrix A that look like this: