<div dir="ltr">agree!<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 7, 2014 at 9:52 PM, L.C. Karssen <span dir="ltr"><<a href="mailto:lennart@karssen.org" target="_blank">lennart@karssen.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Diego,<br>
<div class=""><br>
On 07-04-14 20:08, Diego Fabregat wrote:<br>
> Hi guys,<br>
><br>
> If I may...<br>
<br>
</div>Of course! More than welcome :-).<br>
<br>
I like your suggestion a lot. It's seems the cleanest one, with the<br>
added advantage that it documents the algorithm explicitly in the code.<br>
<br>
<br>
Thanks,<br>
<br>
Lennart.<br>
<div class="HOEnZb"><div class="h5"><br>
>>>> + /*<br>
>>>> + in ProbABEL <0.50 this calculation was performed like t(X)*W<br>
>>>> + This changed to W*X since this is better vectorized since the<br>
>>>> left hand<br>
>>>> + side has more rows: this introduces an additional transpose,<br>
>>>> but can be<br>
>>>> + neglected compared to the speedup this brings(about a factor 2<br>
>>>> for the<br>
>>>> + palinear with 1 predictor)<br>
>>>> + */<br>
>>>> + MatrixXd tXW = W_masked.masked_data->data * X.data;<br>
>>> I think the variable naming should be more apropriate here: tXW sounds<br>
>>> like X^t * W, but you store W * X in that variable.<br>
>> Yepp, your right it should be called tWX. We skip the transpose of W<br>
>> since it is a symmetric matrix: however in terms of mathematics it<br>
>> makes sense to call what we achieve. You can read in the code what we<br>
>> do. This might need some explanation in form of comments.<br>
>>><br>
>>>> + MatrixXd xWx = tXW.transpose() * X.data;<br>
>>> Similarly here, I'm not sure how to interpret xWx. Since you calculate<br>
>>> (W*X)^t * X a name like WXtX seems more reasonable.<br>
>><br>
>> So this will be something like ttWXX ??? Any other good solution?<br>
> I don't know the context of the discussion, but what do you think about<br>
> documenting the algorithm somewhere in the code (like at the top of the<br>
> source file), giving simple names to the variables, and then just using<br>
> those names instead of getting to a point where you have to juggle with<br>
> cryptic variable names. For instance, in case you want to solve a<br>
> least-squares problem inv(X^T X) X^T y:<br>
><br>
> /*<br>
> * Algorithm for LSQ [ b := inv(X^T X) X^T y ]<br>
> *<br>
> * S := X^T X<br>
> * v := X^T y<br>
> * b := inv(S) y (notice that this should be solved as a linear<br>
> system, not explicitly inverting S)<br>
> */<br>
><br>
> And then you can simply use S, v, and b in the code.<br>
><br>
> Best,<br>
> Diego<br>
> _______________________________________________<br>
> genabel-devel mailing list<br>
> <a href="mailto:genabel-devel@lists.r-forge.r-project.org">genabel-devel@lists.r-forge.r-project.org</a><br>
> <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genabel-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genabel-devel</a><br>
<br>
</div></div><div class="HOEnZb"><div class="h5">--<br>
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*<br>
L.C. Karssen<br>
Utrecht<br>
The Netherlands<br>
<br>
<a href="mailto:lennart@karssen.org">lennart@karssen.org</a><br>
<a href="http://blog.karssen.org" target="_blank">http://blog.karssen.org</a><br>
GPG key ID: A88F554A<br>
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-<br>
<br>
</div></div><br>_______________________________________________<br>
genabel-devel mailing list<br>
<a href="mailto:genabel-devel@lists.r-forge.r-project.org">genabel-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genabel-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genabel-devel</a><br></blockquote></div><br><br clear="all">
<br>-- <br>-----------------------------------------------------<br>Yurii S. Aulchenko<br><div><br></div><div>[ <a href="http://nl.linkedin.com/in/yuriiaulchenko" target="_blank">LinkedIn</a> ] [ <a href="http://twitter.com/YuriiAulchenko" target="_blank">Twitter</a> ] [ <a href="http://yurii-aulchenko.blogspot.nl/" target="_blank">Blog</a> ]</div>
</div>