« first day (77 days earlier)      last day (3158 days later) » 

12:00 AM
Yes, you should add that in the post for completeness
 
BTW, I used the difference because it certainly is the discrete approximation
so that isn't valid?
 
Yes, that's correct. The not so correct part is to use the derivative
 
ahhh
 
There's not derivative in a discrete domain
 
Hmmm. It's a bit hard to search for syntax with punctuation marks in google - I'm a bit confused about X = [ones(m, 1), data(:,1)]; specifically data(:,1)
 
12:01 AM
And you can't compare with the spatial approach, which is difference
 
data(:,1) is to get the first column of data.
ahhh.
 
@rayryeng Did you read my email yet?
 
question, why do you multiply by exp?
Yes, I'm reading it now.
 
Ahh okay gotcha
 
Difference in space is multiply by exp in frequency
So 1 - exp(...) is difference in space
 
12:02 AM
is it???
wow... that's a property that I wasn't aware of
 
Yes you are :-)
 
ahhh yes. ok
 
It's the familiar time-shift property
 
yes yes.
That totally makes sense.
so I was basically comparing the wrong things together.
 
The spatial approach is correct
The freq approach had the two problems
 
12:03 AM
right - because we are computing differences in the spatial domain, the time-shift property needs to be used in frequency
 
YEs
Also, imshow autoscales
It masks the real problem
The scales were vastly different
 
yes I see that
 
The freq approach had much larger values because of the "periodic discontnuity"
 
right.
 
So the actual values were seen as about zero
 
12:04 AM
one more question... why subtract by 1?
 
That's the -x[n] in x[n+1]-x[n]
but seen in freq
 
ahhhhh
 
x[n] transformed is X[k]. x[n+1] is X[k] * exp(...)
So x[n+1]-x[n] transformed is X[k](exp (...)- 1)
 
yes, that totally makes sense.
I was going to complete that but you did it for me :)
 
Hehehe
 
12:07 AM
and you cropped out the top/bottom rows and left/right columns because of the large discontinuity between them... assuming that this image is a periodic signal.
 
Yes
Alternatively, you could produce that line in the spatial approach
 
I got it.
How would this work for higher order derivatives?
 
Using something line h([end 1:end], [end 1:end])
 
or sorry, differences?
Yes that makes sense.
 
I guess, but the "1-exp(...)" formula should be revised
Something like 1 -2 1, like the Laplacian
 
12:09 AM
right.
OK, well I'll edit my post so that only the first derivative is considered.
 
Or just apply the first difference sequentially
 
going higher order is going to be probably too complex for the scope of the post.
 
Yes, I wouldn't get into that
I think I should go to bed!
It was an interesting problem :-)
 
Yes most definitely :) Thanks for helping me figure it out.
I should have honestly made a question and have you answer it
you would have at least got some reputation and a bounty
 
No problem! :-) I'm honestly glad I could help, and that's enough
 
12:11 AM
ah :) because you figured it out? lol
yeah I'm going to have to revise that post completely. I'm using the wrong formula.
 
figure out what?
 
I'll have to mention that I'm finding the discrete derivative.
figured out my problem!
it's enough because you figured out the problem :)
 
Ah, yes :-) And because it was fun
 
@LuisMendo - I'm sure it was!
 
By "that's enough" I just meant that helping was a sufficient reward for me. I'm not sure about my English sometimes
 
12:14 AM
oh :)
well thank you regardless. I should have known that I was applying the wrong operation.
So really... there's no way to compute the true derivative calculation in MATLAB.
finite differences are the only way to go given discrete numeric data.
 
Or even there is no way to even define the derivative
 
which is why I have to use another property - not the derivative property.
 
Exactly
 
@LuisMendo - Yes. I'll need to put that into the post. It will require a significant change.
@LuisMendo - I'll apply a bounty on one of your other answers as a token of my appreciation. :)
 
The Wikipedia page has the time-shift property. You may want to link it
In mathematics, the discrete Fourier transform (DFT) converts a finite list of equally spaced samples of a function into the list of coefficients of a finite combination of complex sinusoids, ordered by their frequencies, that has those same sample values. It can be said to convert the sampled function from its original domain (often time or position along a line) to the frequency domain. The input samples are complex numbers (in practice, usually real numbers), and the output coefficients are complex as well. The frequencies of the output sinusoids are integer multiples of a fundamental frequency...
 
12:17 AM
@LuisMendo - Yup I will most certainly.
I will also credit you for helping me find the discrepancy.
 
@rayryeng @rayryeng Hahaha. Well, thanks. There's really no need :-) But thanks ffor your appreciation
 
@LuisMendo - no worries at all :) I would have never figured it out if it wasn't for you.
 
I'm sure you would have :-) But having someone take a fresh look usually helps
It's easier to find it seeing it all "from scratch"
 
@OneRaynyDay - The : symbol depends on the application. When it comes to indexing, using : by itself means to get ALL of a particular dimension.
@LuisMendo - Certainly :)
 
Going to bed now! Bye!
 
12:19 AM
@LuisMendo - Buenas noches!
 
@rayryeng Bonsoir mon ami!
 
merci :)
 
@rayryeng Ah, so you would say [:] to get everything inside of an array?
@LuisMendo and goodnight! :)
 
y = [1 2 3 4 5 6]; x = y(:); means to copy all of y into x. However, the side-effect is that x will now be a COLUMN-vector
y is originally a row vector first off.
The reason why is because MATLAB works in what is known as column-major order. This means that data is populated column-wise first in memory
so by doing this copy operation, you would be making a new variable where the 1D data is copied to a column of a single dimension.
However, if you did x = y;, this is an exact copy, and so x will still be a row vector.
 
ahh... that is so strange
 
12:27 AM
ah not really :)
 
But I understand now! Thanks Ray :) This is even stranger than when I transitioned from java to python in terms of syntax and how stuff works
 
In fact, this is a common way to take a matrix and unroll it into a single vector
When you start the Neural Networks module, this is what you'll see.
For example, given this matrix
A = [1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15];
Doing B = A(:);.... what happens?
B becomes a single vector where you take columns of A and stack them on top of each other
so B becomes: B = [1 6 11 2 7 12 3 8 13 4 9 14 5 10 15]'; %<-- Transposed
 
Ahhh, so it's easy for transposing
 
Yeah going from something like Java to Python requires a bit of a brain bend.
@OneRaynyDay - In a sense yes :)
It's also a very neat trick to ensure that the input data is a column vector.
 
But it's still a very long nth dimensional vector, so you have to do some stuff to bend those values into proper matrix dimensions
I gotcha! :)
 
12:30 AM
@OneRaynyDay - Correct. That's what the reshape command is for.
it takes a 1D vector and moulds it back into a matrix of whatever size you want.
So for example, if I had a vector of A = 1:25;
if I did B = reshape(A, 5, 5);, this means that it'll take my A vector and reshape it to a 5 x 5 matrix
 
Wait that's so useful actually
 
remember, COLUMNS are populated first... so what you get is:
B = [1 6 11 16 21; 2 7 12 17 22; 3 8 13 18 23; 4 9 14 19 24; 5 10 15 20 25];
 
Oh yeah, I gotcha :) It's just super helpful for transposing
 
Totally.
 
Thanks Ray! It seems like I have to bend my brain a bit for matlab too
 
12:32 AM
@OneRaynyDay - Yes :) you'll get used to it.
 
It's a good bend though haha, thanks for going through the functionalities with me!
 
that's just skimming the surface lol
but no worries :)
 
I'm happy to have made this public, for your review guys:
2D Affine Transforms 101 https://github.com/legends2k/2d-transforms-101/#2d-affine-transforms-101
in case, if you're interested i.e. :)
 
cool~
alright guys. I'll brb
 
me too, need to get ready for the day
 
12:38 AM
aighty!
@legends2k And wow you made that? It looks super well designed
Oh wow bravo man, this is really nice haha
 
 
2 hours later…
2:44 AM
Wow, took me a surprisingly long time to finish the matlab assignment
I can't seem to intuitively understand how to compute matrices without for loops X_X
I did this in java in about 4 minutes, while doing it with matrices on matlab took me like... 20 minutes
 
What are you trying to compute?
 
x refers to the population size in 10,000s and y refers to the profit in $10,000s
It's just the gradient descent equation, theta(i) = tempTheta(i) - alpha*(sum((X*tempTheta - Y).*X(:,i))/m)
 
ah
well gradient descent you NEED to use loops.
you don't have a choice there.
Because you are ITERATING towards the final solution. That's expected.
 
right, but I did some iteration in java
because there was no matrix operation support
So it was iterations inside iterations inside iterations
In matlab it was done with only like 1 for loop through# of iterations, but I had to multiply matrices and stuff - got super confused xD
 
Yup lol
did you try any of the linear algebra libraries?
JBLAS or the Armadillo wrapper, or java netcdf?
 
2:58 AM
for java? Not yet :) I have JBLAS added as a dependency in Maven for my project though!
So it's all ready to go in case I want to use it in the future ^_^
 
cool!
 
Hey ray, could you help me with understanding this part of the code?
it's just GUI but I'm still a bit confused
 
yeah what's up?
 
Mmm, I'll paste it in a pastebin since it's a bit thick for the chat room ^_^
 
sure
 
3:03 AM
So a part of it makes a contour plot for 3d graph, and the other is an actual 3d graph like the sceenshot I had above
but I have no idea what the code means xD
 
OK. Lines 3 and 4 define a set of x and y values. x is theta0 and y is theta1.
The next part is a pair of for loops that iterate over each unique pair of theta0 and theta1 which computes the cost function of your data values given a pair of theta0 and theta1.
These are stored in a matrix called J_vals
However, with the way the matrix is currently defined, the origin is assumed to be at the top-left corner.
You need the origin to be at the BOTTOM-LEFT corner when you're plotting things... just like in Cartesian coordinates.
 
ahhh I see
 
that's why the transpose of the matrix is taken
to make the origin go from the top-left corner to the bottom-left.
The next command is surfwhich plots a surface plot.
it's a 3D plot where the first input is a set of x values, the next input is a set of y values, and the last value is 2D matrix that corresponds to each unique (x,y) pair.
let's do an example... suppose that theta0 = [-1 0 1]
and theta1 = [1 2 3]
what will happen is that you will now get a 3 x 3 grid of spatial coordinates. Assuming that theta0 is on the x and theta1 is on the y, it would look like this (remember that bottom-left is the origin)
>> theta0

theta0 =

     1     1     1
     0     0     0
    -1    -1    -1

>> theta1

theta1 =

     1     2     3
     1     2     3
     1     2     3
 
ahhh I see... so
 
For each pair of theta0,theta1, there's a unique value of J that maps to that location
so you're basically plotting a 3D plot where each point on the surface is a cost for that pair of theta.
so with gradient descent, the job is to find the minimum of this surface.
Now what contour does is very similar.
What it does is that it draws rings of different colours
Each colour represents different HEIGHTS of the surface.
so imagine the surface being projected onto the x,y plane.
 
3:15 AM
Ah yeah, and the colour is from the 3rd 2d matrix that's being inputted?
 
The heights are automatically coloured based on the height.
The default colour map is known as the parula colour map
if you want to change the colour map you can. Try doing colormap hsv; or colormap jet; after the plot is open and see what it looks like
the colouring is just for visual effect.
If you want to see something even cooler, type in colorbar while the plot is open
it gives you a visual mapping of what height maps to what colour.
 
ahh I see
so I type colorbar into the terminal window?
 
yup
that's when the plot window is open.
You'll see it appear on the right hand side
it gives you a visual mapping that tells you what height of your surface maps to each colour
 
ah that's so cool! :)
 
if you want a slightly better look
type in shading interp;
Right now, surf takes each point and draws a colour square and surrounds it with black borders.
If you have ALOT of points, it looks like a completely dark plot, which looks bad.
shading interp; essentially removes the black lines and interpolates in between the colours instead.
 
3:19 AM
ahh
Wait I'm typing it but I still see the mesh
oh nevermind - got it!
I forgot the semicolon
 
oh :D lol ok
weird. that shouldn't change anything
but ok!
 
yeah haha I thought so too :)
Wow this is super cool actually LOL
matlab's graphing is so neat
 
To be honest, it's a port of gnuplot :)
but the syntax is much easier lol
 
Oh... it's ported? LOL woops
 
that's fine :)
MATLAB essentially borrows from a lot of other packages, and also adds their own things to make it easier.
 
3:22 AM
Yeah matlab's syntax is so easy that I feel uncomfortable with it initially
 
For example, a lot of the linear algebra operations are calling BLAS and LAPACK under the hood.
 
right, I can see that :)
 
MATLAB's Fourier Transform uses some calls to FFTW
The Computer Vision Toolbox uses some of OpenCV's functions.
 
Ah - is it safe to assume OpenCV is industrial grade?
 
so there are some packages from the outside that are consolidated in MATLAB but with an easy to use interface.
Yes. I'm actually using it in some of my applications.
at least on the server side.
You'll also see me answer the odd OpenCV question on SO sometimes
 
3:25 AM
Ahh I see :) I think OpenCV is super cool - want to make some application with it some time
 
lots of tutorials to get you started!
 
Right! First priority is still machine learning though haha ^_^
 
yup :)
Does the code make sense?
I talked about contour. Not sure if you saw it
but basically think of your surface as being sliced over different heights.
these slices are projected onto the x,y plane.
you then draw around the perimeter of these slices and that's what you see on the plot
each colour trace gives you what the height of the function is at.
That's how people visualized 3D figures way back when.
 
Right yeah, I didn't chat about it but I read it all don't worry! :)
I understood that part so I didn't raise any objections to it
 
cool!
 
3:30 AM
Thanks Ray! You explain stuff really really well tbh
 
@OneRaynyDay - ah :)
well you're getting my teaching experience.
I taught courses as a part-time instructor when I was doing my PhD.
not to boast, but I got prof of the year 3 times in a row
I lost the 4th time because I graduated :)
and you're welcome!
 
Wow, 3 times in a row?!
Well I wouldn't be too surprised since it does show :)
Sounds awesome though, I'd totally pay 45 bucks for you to tutor me for an hour later on haha
In the silicon valley, I've gotten tutors for history/math who never really done much and their average wage was like 40 dollars per hour...
I think maybe it's because of the desperate asian parents trying to boost the GPA's of the kids, or the fact that people are too competitive about grades, but
if you came to SV to tutor people about comp sci, I think you'd make like 70$ per hour doing that kind of stuff ^_^
Well anyways, I'll be back! Gotta go get my work out in - be back in an hour or two perhaps
 
sure! take it easy
well thanks for the compliments :D
 
 
2 hours later…
5:22 AM
@Divakar - Mr. bsxfun!
 
:P
Though I would peek in for a quickie :)
 
haha! how's it going?
I'm going through the comment you wrote.
 
haha does that make sense?
getting the intermediate outputs might put more sense!
 
oh no problem, it does.
I don't need to. I can picture it in my head.
the right side of that statement finds all of the odd occurring indices.
 
awesome!
 
5:27 AM
multiplying cumsum by M is quite ingenious.
 
yeahhh that was good find I thought.
 
You basically replace all 1 values with their rolling sum at each column
That's a trick I HAVE TO REMEMBER.
 
I wasnt expecting it to be two liner though, before starting on solving it.
 
once you mod it, the values that are 1 are odd.
I don't think I could get it any shorter. It's a very well thought piece of code.
 
yeah, one can use some logical operation instead of -.
 
5:29 AM
Yeah the M.*cumsum(M) is a great trick to know. There have been many times where I wanted to replace a sparse column of 1s with an incremental counter going from 1 up to as many non-zero entries.
It's good to know without the use of indexing. Great for golfing.
 
oh sparse isnt my forte, so wont go that way often
 
haha no problem :)
but M.*cumsum(M) is a great trick. Thanks for showing us!
 
yeah Luis is great too with all these tricks, one can learn a lot from his solutions too
sure! :)
I am just glad bsxfun gets one more usage ;)
 
Speaking of Luis, he helped me figure out a bug in one of my earlier posts. I need to go fix it.
 
well I gotta go, good to see you again!
keep SOingg!
 
5:36 AM
ok! thanks buddy!
Take care!
I'll tell Luis you said hello :)
 
6:35 AM
agh, sorry guys! I would've come back earlier but
had some family issues that I had to take care of
 
7:10 AM
no worries.
 
7:42 AM
@LuisMendo - Post is now edited. Thank you so much :)
9
A: Finding the derivative of a 2D function using FFT properties

rayryengDisclaimer - Edit on September 16th, 2015 This post has significantly changed due to a small yet fundamental flaw in my understanding of the derivative operation in the frequency domain. A lot of this post has changed since the previous iteration. I would like to thank Luis Mendo for helping m...

 
7:59 AM
very cool post. Shouldve read that last december
(and it's 16th september 2015 or 2015 september 16, largest to smallest or smallest to largest, stupid Americans...)
 
haha adriaan you really dont like americans huh
 
mwoah, I especially don't like them mutilating a beautiful language and using absolutely arbitrary units, for which you should be ceremonially crucified.
 
^ I totally agree with that
I still haven't learned how many yards there are in a mile
 
1682 or something arbitrary
1760 according to the graph :P
 
yeah, I don't think even us Americans know to be honest LOL
don't worry, every single science class uses the metrics system
 
8:05 AM
it's interesting to do Quantum Mechanics with Americans "It's 1/1.000.000th of an inch!"
oh, I missed 3 zeros there, my bad
 
LOL, the people who use inch in things that are not commonplace are probably the classic hillbillies who never passed secondary education
 
isn't that most of the USA?
 
@Adriaan - I am Canadian.
Calling me an American is an insult (no offence).
 
@rayryeng I know, it's just that the US goes prat on using that
 
And thus I'll be super surprised when you find a hill billy with quantum mechanics knowledge
 
8:08 AM
apologies, I did not intend to do that
 
@Adriaan - hehe ok... and thanks for the compliments :)
@Adriaan - no problem. I was joking too.
 
I havent had my third mug of coffee yet :(
 
@Adriaan - Yeah. Someone contacted me regarding that post and was wondering why it wasn't working for their image.
I couldn't figure out, so Luis helped me debug what was wrong. That's why I edited the post
in fact, if you search on Google and type in 2D FFT Derivative, the first post that comes up is my answer.
 
@Adriaan Nah, people in America(including me) who are aware of how inconvenient the american measurement system feel the same way adriaan XD
 
I read the transcript, interesting discussion. Could follow most of it
 
8:09 AM
I don't want anyone using my post to have the wrong information.
 
such as wrong dates? ^^
 
North America does it Month, Day, Year
So that's what I'm going to do.
 
Since when does stackoverflow support chatting?
Hello fellow MATLAB users
 
@Wauzl - It always has!
Greetings!
 
Never met my eye, I guess
 
8:11 AM
@Adriaan - yes, I never understood imperial measurements. I was brought up metric.
 
I think metric is much easier to use, but I guess whoever likes imperial should just use it
So, whats your favourite spy picture?
 
Canada was imperial for the longest time until the late 70s.
They lobbied for metric and it stuck.
 
@rayryeng I did a lot of petroleum courses during my Earth Sciences bachelor. It's about the most conservative business on Earth, so all assignment were in imperial units and thus 85% failed the class because no-one could make head or tails of it.
 
hahahahahahaha
oh boy. that's funny... unfortunate though
 
Imperial are for bakers, the unruly rebels who dare to disestablish the hallowed systems of our 21st century mathematicians - a truly terrifying thought
2
 
8:13 AM
unfortunately I do need to go. It's 0413 here.
I'll catch up tomorrow! Good night folks.
 
teacher was a big Texan who'd worked in the industry for years, had a hard time understanding him :P
good night @rayryeng
 
Ah yeah, I see you up at night super late ray xD goodnight!
 
I just stapled >80 sheets of paper. THIS IS SO MUCH FUN.
Its 10:15 here and I'm procastinating, because I have to write a Mather thesis
entertain me
 
Let meeeeeee Entertaaaiiin yoooooouuuuuuuu!
 
do something mathy
 
8:17 AM
my class on complex analysis is starting in 27 minutes, and Im still wearing pyjamas
 
wait you can download a full transcript of this room? You shouldve told me earlier
oh complex analysis is so elegant
I has a solution, you only has comment
I is better then you
 
learning ML from coursera right now
Andrew Ng is writing stuff to display octave functions on the terminal when suddenly he writes in the terminal
"WHOOPS PLEASE EDIT"
 
lol?
there is a coursera course for matlab?
 
8:32 AM
octave and matlab!
 
Well, I'm not a big fan of octave
I need more matlab questions... i feel bad for procrastinating, if i dont do anything
 
ah, have never used octave so I wouldnt know :)
 
so, go ahead and type why in your matlab
 
........ The bald and not excessively bald and not excessively smart hamster obeyed a terrified and not excessively terrified hamster.
 
Do it all over again
and again
Why you ask? Well--- The programmer suggested it.
 
8:45 AM
To fool the tall good and smart system manager.The rich rich and tall and good system manager suggested it.He wanted it that way.The programmer suggested it.
why
 
Still not fun enough? Type spy and watch
 
while true do why end
this is so amusing omg LOL
well anyways, thanks for the laughs man, I'm about to go to sleep! Night :) Frequent this chat more often
 
cya
 
9:05 AM
Thanks for mentioning me in the post!
In the first equation with the Fourier transform (shift theorem), I think m should be 1 (or an m is missing in the RHS) @rayryeng
 
 
2 hours later…
11:19 AM
0
Q: Matlab Coder and parfor in Matlab-r2014b

user3285148Does Matlab Coder in Matlab-r2014b support parfor? If I check at http://uk.mathworks.com/help/simulink/ug/functions-supported-for-code-generation--alphabetical-list.html, it reports: "Treated as a for-loop in a MATLAB Function block". Does that mean that there is no speed reduction?

I was rather tempted to answer this in the style of @rayryeng with a simple "yes".
He couldve just read the link he provided.
Bah. OP stole my full edit... All he did was change "reduction" to "improvement" additionally. There goes a refiner notch
 
 
1 hour later…
12:48 PM
boo, hey binary friends
 

« first day (77 days earlier)      last day (3158 days later) »