I know it's just an example, but it's funny to me that in the example of using CSC to efficiently store a sparse matrix, we're using 16 numbers to store a 3x3 matrix.
This concept of breaking a matrix down to the sum of rank one outer product matrixes is covered in depth over many lectures in the first half of the OCW course 18.065 taught by Gilbert Strang.
It's great fun to reproduce the lecture with Pluto.jl. It would be nice to get hints which packages you are using. Most are trivial but which package does the "with_terminal" function come from?
Why is it that we have to write *Base.size(x::OneHot) = (x.n, )* and not just size(x::OneHot) = (x.n, )? Normally we just write size(vector) and it works. Why do we need to specify the library an attribute is coming from when defining a new type in Julia? I'm just trying to understand the logic here. What could go wrong if we were allowed to write just size(...) inside a struct, given that it works perfectly fine outside a struct?
In Julia, if you want to create new methods for a generic function defined in a separate module (like Base), usually you use Module.function syntax. If you want to *not* have to do that, you have to use the `import` keyword, which allows extending behavior by adding new methods. See the "Modules" section in the Julia manual for more details.
I can't get the factor function to work. Is the code correct for sure? When I try factor(outer([1,2,3], [2,2,2])), it tells me "Input is not a multiplication table". If you want to play with it, here's the code: outer(v, w) = [x*y for x ∈ v, y ∈ w] function factor(mult_table) v = mult_table[:, 1] w = mult_table[1, :] if v[1] != 0 w /= w/v[1] end if outer(v,w) == mult_table return v, w else error("Input is not a multiplication table") end end
Also, I think when v[1] = 0, leaving v and w unchanged in the code is not right. Consider v = [0, 1, 2, 3] and w = [1, 2, 3, 4], so mult_table = outer(v, w) = [[0, 0, 0, 0], [1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12]]. You would not be able to factor this multiplication table using this code. It would try v = [0, 1, 2, 3] and w = [0, 0, 0, 0], and since the outer product (zero matrix) is not equal to the multiplication table, it would say "Input is not a multiplication table".
Is it me or the sound is only listened on the left?
If it hurts too much you can switch on "mono sound" in "ease of access sound settings" in Windows.
Here's a neat, concise definition of outer I just cooked up;
outer(a, b) = a .* b'
I have a question.
Does Philip come to the lecture on his own or you bring him in ?
I know it's just an example, but it's funny to me that in the example of using CSC to efficiently store a sparse matrix, we're using 16 numbers to store a 3x3 matrix.
my right ear is jealous
that SVD explanation though
the "Compressing matrices using outer products" was new to me and super cool :)!
This concept of breaking a matrix down to the sum of rank one outer product matrixes is covered in depth over many lectures in the first half of the OCW course 18.065 taught by Gilbert Strang.
It's great fun to reproduce the lecture with Pluto.jl. It would be nice to get hints which packages you are using. Most are trivial but which package does the "with_terminal" function come from?
github.com/mitmath/18S191/blob/master/lecture_notebooks/week3/01-structure.jl#L20-L24
That's from PlutoUI (github.com/fonsp/PlutoUI.jl)
Can you add the link to the repo in the description? I'd like to peep the notebook
See mitmath/18S191 on GitHub
Why is it that we have to write *Base.size(x::OneHot) = (x.n, )* and not just size(x::OneHot) = (x.n, )? Normally we just write size(vector) and it works. Why do we need to specify the library an attribute is coming from when defining a new type in Julia? I'm just trying to understand the logic here. What could go wrong if we were allowed to write just size(...) inside a struct, given that it works perfectly fine outside a struct?
In Julia, if you want to create new methods for a generic function defined in a separate module (like Base), usually you use Module.function syntax. If you want to *not* have to do that, you have to use the `import` keyword, which allows extending behavior by adding new methods. See the "Modules" section in the Julia manual for more details.
Thank you very much !
I can't get the factor function to work. Is the code correct for sure? When I try factor(outer([1,2,3], [2,2,2])), it tells me "Input is not a multiplication table".
If you want to play with it, here's the code:
outer(v, w) = [x*y for x ∈ v, y ∈ w]
function factor(mult_table)
v = mult_table[:, 1]
w = mult_table[1, :]
if v[1] != 0 w /= w/v[1] end
if outer(v,w) == mult_table
return v, w
else
error("Input is not a multiplication table")
end
end
Also, I think when v[1] = 0, leaving v and w unchanged in the code is not right. Consider v = [0, 1, 2, 3] and w = [1, 2, 3, 4], so mult_table = outer(v, w) = [[0, 0, 0, 0], [1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12]]. You would not be able to factor this multiplication table using this code. It would try v = [0, 1, 2, 3] and w = [0, 0, 0, 0], and since the outer product (zero matrix) is not equal to the multiplication table, it would say "Input is not a multiplication table".
(If your sound is only in one speaker please click on over to ua-cam.com/video/zoUeUG-Sm6g/v-deo.html )
Hi Alan the sound encoding is only mono!
Hopefully fixed? ua-cam.com/video/zoUeUG-Sm6g/v-deo.html
Thanks! Perhaps you could remove this video and replace it with the reupload?
@@TheJuliaLanguage Thanks! The course website still links to this mono video, by the way. computationalthinking.mit.edu/Fall20/lecture5/
@@TheJuliaLanguage thanks, could you fix the playlist to use that version?
Tedata