John
Reputation
1,856
Next privilege 2,000 Rep.
 Dec 4 comment Applying several patterns to Split I like your approach better from the perspective of comprehension. However, LeonidShifrins approach is faster. Nov 27 comment Determining the week of a year from a given date @Heike stevenvh is right. Is there a way to avoid these two problems (week 0 and week 53)? Nov 27 comment Determining the week of a year from a given date Why would 2010-01-01 return week 53? Doesn't one year only contain 52 weeks? Nov 27 comment Determining the week of a year from a given date I was not aware of using Java within Mathematica. What you wrote sounds interesting. Can you recommend any website or so where I can learn more from implementing java-code into Mathematica and also on available java-scripts? Nov 26 comment Usage of plot results @SimonWoods Two more things I did not mentioned before: (1) It would be nice to have the button to appear above the line and (2) if the button touches one of the PlotMarkers Clipboard should only copy the corresponding data-point. Nov 23 comment Usage of plot results @SimonWoods The behaviour of the button is a bit strange. It does not change its colour immediately when I touch another line. (Maybe my Mac is reacting to slow?) Nov 9 comment Leveling peaks in list Almost. With {a___, b_, c_, d_, e___} instead of {a__, b_, c_, d_, e__} it works. (i.e. BlankNullSequence instead of BlankSequence) Nov 9 comment Leveling peaks in list The following works but maybe there is a better approach: first = {left_, right_, rest___} /; left > right :> {left/2, left/2, right, rest}; sec = {rest___, left_, right_} /; right > left :> {rest, Mean[{left, right}], Mean[{left, right}]}; third = {a___, b_, c_, d_, e___} /; b < c > d :> {a, Mean[{b, c}], Mean[{b, c}], d, e}; (# //. first //. sec //. third) & @ data Nov 8 comment Leveling peaks in list An extreme value is always to be levelled if its neighbour is lower (e.g. dataNoLevelling={1,5,5,5,1} -> (*resNoLevelling={1,5,5,5,1}*)and dataLevelling={100,5,5,5,100} -> (*resLevelling={50,50,5,5,52.5,52,5}*) Nov 8 comment Leveling peaks in list I just discovered that there is one problem with your approach. Lets say you have data={10,0,0,0,10}. Then both, the first and the last value, are extrem values which I would like to level as described. I did not pay attention to this case when I asked my question. The problem I see, is that the approach must extend data to the left. (desired result: res={5,5,0,0,5,5}. Note: Length@res-Length@data=1) Nov 5 comment Restricted accumulation of values @J.M. What about the If-clause? Do have an idea how one could substitute this part of my code with another expression? Nov 2 comment Restricted accumulation of values @J.M. I'm not really a fan of If (I got the prejudice that it slows down calculations) but I wonder whether in this case really another approach would be faster. Nov 2 comment Restricted accumulation of values @MikeHoneychurch The code-line with FoldList is only there to describe how I got to the last code-line. The most crucial point to me was to formulate an alternative to Accumulate with the addition of implementing conditions. Nov 1 comment Restricted accumulation of values @acl I added your advice. Oct 22 comment Why is an integer not considered as a real? @rm-rf This is the answer I was looking for :) If you guys still think we should close this post please do so. Oct 22 comment Why is an integer not considered as a real? @rm-rf I agree, the question is a duplicate but as I mentioned the answers do not match. Please see edit. Oct 22 comment Why is an integer not considered as a real? @Mr.Wizard The answers to your quoted question do not answer my question. Please consider the following: zeros = {0, 0.}; sets = {Integers, Reals, Complexes}; eTest=Table[Element[zeros[[j]], sets[[i]]], {i, 3}, {j, 2}] However, Mathematica returns for 0==0. False as J.M. pointed out in his question. Oct 8 comment How do I get rid of a “jump” in my plot? @J.M. I'm not familiar with AstronomicalData but maybe it is possible to produce the data via Table (i.e. wrapping AstronomicalData with Table) and then to use ListLinePlot with InterpolationOrder->3. Aug 24 comment Changing background colour of a Manipulate element @kguler please check Nasser M. Abassis' comment on wrappers around Manipulate and demos. Aug 24 comment Changing background colour of a Manipulate element @NasserM.Abbasi Good advice, because I intend to deploy my notebook as a CDF. Would the wrapper cause problems then? If so, I may post a new thread on this issue.