Timeline for Returning a function built with local (block) variables
Current License: CC BY-SA 3.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 8, 2017 at 22:20 | history | tweeted | twitter.com/StackMma/status/906281142915084288 | ||
Sep 8, 2017 at 15:08 | answer | added | Mr.Wizard | timeline score: 4 | |
Sep 8, 2017 at 13:55 | comment | added | giulio bullsaver | @Szabolcs thank you! I guess this With[{mu= mu0,...] solution is the one I like best! | |
Sep 8, 2017 at 13:45 | comment | added | Lukas Lang |
Could it be that there's an issue with the ordering of the indexes for data ? Judging from m=data//Length , data seems to be a $n\times 2$ array, but later you're accessing it with i as first index, with $i\in\{1,2\}$
|
|
Sep 8, 2017 at 12:52 | comment | added | Szabolcs |
Actually you should not be using Block here because the results will be messed up if data contains \[Mu] (or even i ). Generally, stick to Module unless you know that you need Block . If you use Module , you will need separate mu and mu0 due to Module 's symbol renaming.
|
|
Sep 8, 2017 at 12:47 | comment | added | Szabolcs |
Re your update: Once you've calculated $\mu$ and $\sigma$ and stored them into mu0 and sigma0 , use With to inject them. With[{mu = mu0, sigma = sigma0}, Function[..., ... mu ... sigma ...]] . In fact you can even just use mu and sigma throughout (not mu0 ) and do With[{mu=mu, sigma=sigma}, ...] . If this is confusing to you, stick to separate names (mu and mu0 ).
|
|
Sep 8, 2017 at 12:43 | comment | added | Szabolcs |
Why do you keep using Return and extra semicolons when they are not necessary (even even hurt performance)? Use Block[{}, ...; result] , not Block[{}, ...; x = result; Return[x];] .
|
|
Sep 8, 2017 at 12:19 | history | edited | giulio bullsaver | CC BY-SA 3.0 |
reformulate the problem
|
Sep 8, 2017 at 11:47 | answer | added | Szabolcs | timeline score: 9 | |
Sep 8, 2017 at 11:47 | answer | added | Lukas Lang | timeline score: 5 | |
Sep 8, 2017 at 11:45 | history | edited | giulio bullsaver | CC BY-SA 3.0 |
typos
|
Sep 8, 2017 at 11:45 | comment | added | giulio bullsaver | Sorry, I misswrote the code, now is correct. | |
Sep 8, 2017 at 11:41 | review | First posts | |||
Sep 8, 2017 at 11:47 | |||||
Sep 8, 2017 at 11:38 | history | asked | giulio bullsaver | CC BY-SA 3.0 |