@Jens, you don't have to be that pedantic, if you don't want to answer the question then don't. If you think the title should be different you can edit the question and type your proposed title. — Barefeg26 mins ago
@MichaelE2 ha, yes. I suppose he's thinking "not evaluate the arguments of the derivatives", or something along those lines. but still, the question as worded is hard to interpret correctly
@acl, OK. First, do you have a suggestion for a better title? Second, I assume both of you don't know the answer otherwise I don't see why the title should matter in order to get the answer. — Barefeg8 mins ago
I was recently interviewed by this guy about using M for stats. Thought I'd point out his blog post and suggest others make comments as they see fit. statisticsblog.com
3
@sjo
@SjoerdC.deVries I think you might be an ideal person to look this over.
I also wanted to see if halirutan's answer on my IterationLimit question offered a way to get the counter. Got lazy too. Same for the tail recursion question
Creating my first Mathematica package and am reading through some of the builtin packages, what on earth is the point of doing SetAttributes[ANOVA,ReadProtected]; in "AddOns/Packages/ANOVA/ANOVA.m"?
since all definitions are still readable by just opening up the .m
@ssch good question. My guess: if the package ever gets pulled into System` , then no changes have to be made. Until then, you're right. There doesn't seem to be much point.
@ssch Yes. It comes from a long time ago, when there was no FrontEnd and people used text editors and Kernel interace only ( I did that on Dos, back in 1991 or so ..., then Unix)
@rcollyer Have to correct exams, just trying to warm up. And go on with some funny webMathematica project (where @Leonid condoled me because I have to meta-program SetDelayed (kind of fun: suppose you want ot manipulate a package programmatically: use Import[ ... "HeldExpressions"] . Then you manipulate the HoldComplete expressions. Nasty, but nice)
@ssch usually, this will be done to aid debugging of user code. It avoids all the package internals showing up in a Trace and stops the user from being exposed to irrelevant and possibly confusing implementation detail.
@RolfMertig I always hate manipulating Hold and HoldComplete. Had to extract some examples (by some I mean all of them) from the docs, so I feel your pain.
@ssch In addition to what @RolfMertig and @OleksandrR. said, I add ReadProtected, Protected, Locked for my packages that I eventually share with others, because then if something isn't working correct in their version and mine, it is almost definitely because they tinkered with the .m file (i.e., you can't unprotect to add definitions, etc.)
@rm-rf personally I think Locked is just an inconvenience to the user. One already has to make a concerted effort to remove attributes, so unless there's a symbol that if it's changed will break the whole system, I wouldn't use Locked myself.
@OleksandrR. I believe the same too, except I want them to explicitly alter the file I gave them before they can :D I mean, if they really need that functionality, they'll know what to do with it.
Of course, these are small packages not meant for mass use... I'm sure my approach is unreasonable if it were, say, a package aimed at a wide audience for the reasons you mentioned.
btw, @ssch's gravatar reminds me of @Mr.Wizard's old one...
Which was the setting that controlled the tolerance of Equal?
I need to change this to get Union, Complement, etc. to take it into account while preserving good performance. Ideally change it in a localized environment (like Block...)
@Mr.Wizard Thanks and thanks to everyone who voted on my stuff so that I'm no longer a teenager anymore but instead can call myself to be in my twenties ;-)
@OleksandrR. It's a list of 2D points. First I'll see if I can get rid of the machine precision comparisions. If it's not convenient, I'll use Compile as you suggested
It would be good if I had just numbers, not 2D points. But maybe I can make the bin size very large in one direction
But I also have Complement, not just Union, so I want to go through the code and check if I can get rid of these comparisions completely. Sometimes I am working with the indexes of the points in a list, and comparison is not a problem there. But the indexes change when the list of points changes. I need to check if I can still keep working with the indexes.
@hhh If you are more comfortable with it then just compare it to java:
import com.intellij.lang.PsiBuilder;
and now replace the .'s in java to ` in Mathematica
Please further note, that in both languages the context (package) separator can be viewed as directory separator and that it matches the underlying filesystem-structure.
@OleksandrR. I'm implementing an adaptive sampling algorithm, like here. Sometimes I get duplicate points (that come from different calculations) for various reasons, and it is not easy to avoid this. I need to filter out duplicate points. I used to do this using Union, trusting that it has a bit of tolerance, but it seems it doesn't ...
@Szabolcs Couldn't you just write a compare func for Sort which sorts your points wrt the distance and then throw out points which have distance < eps?
@halirutan Did you source the file before removal inside Mathematica? So did it have the test file as environment thing? If you close Mathematica and then do the "<<test`", it should not work.
I have a set of 2D points with machine precision coordinates. I need to remove all duplicates. Performance is important.
This is the most obvious fast solution:
Union[points]
Side note: Union[] is much faster than DeleteDuplicates because it relies on sorting, and thus only needs $\sim n \l...
@hhh You should try to not ask the first question that pops into your head. You've now asked several questions in chat and main of the form "What is the equivalent command for randomFunction in Mathematica 8" — there isn't. You'll have to implement randomFunction yourself, and almost always, the page/notebook you refer has the implementation
@CBenni no, this is very well known and probably how 99.9 % of functions behave (e.g. Integrate[Sin[x], {x, 0, N@Pi/3}]), so everyone will probably end up voting it as "too localized" =)
@Searke While I have you here, do you know why the following doesn't return an integer for the second case Head /@ Rationalize@{5.4 10^10, 5.4 10^11} and returns the same number?
@Szabolcs No luck. Even the most direct way using Gather[r]; (where you could extract e.g. the first element of each gathered list) is slower than your approach.
@halirutan because these actually are SameQ. Despite claims in the documentation neither Gather nor DeleteDuplicatesactually use SameQ. They use a smaller tolerance than that.
Compilation and numerics are both rather subtle and mostly undocumented areas in Mathematica, so the more people who become familiar with them, the better, IMO
It is not surprising that DeleteDuplicates[{5,5.}] returns {5,5.} because DeleteDuplicates uses SameQ by default, and SameQ[5,5.] is False.
However, Equal[5,5.] is True, but DeleteDuplicates[{5,5.},Equal] still returns {5,5.}.
It is interesting to note that Union works properly, in that Union[{...