« first day (461 days earlier)      last day (4029 days later) » 

5:26 AM
I need a function that takes a list {x_1, x_2, x_3, ..., x_n} (for example) and returns {{x_1, x_2},{x_2,x_3},...{x_(n-1),x_n}}. My current function is Transpose@{Drop[#, -1], Drop[#, 1]} &@. Is there a better way?
 
5:42 AM
@VincentTjeng Oh, wait... you don't need the reverse. It's simpler then: Partition[list, 2, 1]
 
thank you!
I have no Idea how I missed that
 
6:05 AM
@rm-rf just a quick follow up - is it possible to take the list {x_1,x_2,x_3,...x_n} and return {{x_1},{x_1,x_2},{x_1,x_2,x_3},{x_2,x_3,x_4},...,{x_(n-3),x_(n-2),x_(n-1)},{x_(n-2),x_(n-1),x_n},{x_(n-1),x_n},{x_n}}?
 
@VincentTjeng Yup... also with Partition. Look into the additional arguments (they control the overhangs)
 
Partition[Range[10], 3, 1, {-1, 1}, {}]
thanks!
that does the job
 
0
Q: Is it acceptable to ask short questions in chat?

Vincent TjengSomeone recently mentioned in chat that asking questions in chat is unwelcome behavior. Personally, I ask some short questions which I feel shouldn't be asked as a proper question on the main site, in particular short optimization questions or questions involving opinion. Can I get a sense from t...

 
6:36 AM
@VincentTjeng btw, although not very well documented, the fourth argument can also take values other than {±1, ±1} (useful if you want different lengths hanging on each end)
 
yep!
i'm writing a short snippet of code to compare each value with the preceding and subsequent n values to determine whether it is an extrema
what I have in the end is extremaPosition =
Flatten@Position[
Map[#, Partition[valueList, 2*aroundRange + 1,
1, {-(1 + aroundRange), 1 + aroundRange}, {}]] -
tempvaluelist, 0.] &;
so we can have extremaPosition[Min] or extremaPosition[Max]
 
so you're just trying to find local maxima/minima?
 
yes, and I saw several question on that
but most of them seemed to be addressed at local maxima / minima of functions
or local maxima / minima determined by comparing with only adjacent values
the purpose of my code is to handle noisy data.
 
@VincentTjeng Hmm... there was one (maybe more) on lists
Some even on noisy lists
8
Q: Find the minima and maxima of a list

user5990I have a list, such as: testdata = {{1, 317}, {2, 317}, {3, 317}, {4, 317}, {5, 317}, {6, 317}, {7, 318}, {8, 318}, {9, 318}, {10, 318}, {11, 319}, {12, 319}, {13, 319}, {14, 319}, {15, 314}, {16, 314}, {17, 314}, {18, 314}, {19, 314}, {20, 314}, {21, 314}, {22, 314}, {23, 314}, {...

 
let me keep searching then. I was faced by this problem quite a number of times until I decided that I needed to write the code myself.
temptimelist = Range[200]/10;
tempvaluelist = (Sin[#]/#) &@temptimelist +
RandomReal[{-1, 1}, 200]*0.02;
this is some example data.
what I want to do is to extract the peaks and troughs for this data (which you can see by removing the RandomReal bit)
 
6:43 AM
@VincentTjeng (btw Sin@#/# == Sinc@#)
 
nice catch :)
 
@rm-rf what about this one:
0
Q: making axis numbers larger on Mathematica plot

olliepowerI want the numbers along the axis to be larger than the default value. Can this be done? The reason I am asking is because i frequently make charts in mathematica and use them in word. I export the charts as .bmp files and then paste the images in word. The default text size for the axis is...

 
@YvesKlett What about that one?
 
This is just so RTFM... on the other hand it might be helpful
 
@YvesKlett for a moment i was thinking how it was related to my question :)
 
6:44 AM
@VincentTjeng nonono :-)
 
@YvesKlett Yeah... well, definitely not something I'm going to close single handedly though. If you want to, that's fine (there might actually be some detailed dupes on this... hard to imagine this has never been asked). You could still make an instructive answer out of it by discussing alternatives to Directive (which wolfies has done), such as changing BaseStyle.
Come to think of it, I'm positive there was an answer by @mr.wizard on designing custom styles and just applying it to the plot on demand instead of modifying the default options... too sleepy to search now though
 
@rm-rf no, I was not thinking about getting you to close it - I was on the brink of voting to do so, but the the refreshingly direct (if not pretty) title might be helpful for newcomers.
 
Ah yes, definitely...
 
@rm-rf I think I'll post my question as a proper question with examples!
thanks for helping :)
 
@VincentTjeng No problem :)
 
6:52 AM
@rm-rf sleep away...
 
@VincentTjeng btw, another related one:
4
Q: Local max/min of Mathematica data sets

giacomoIs there a way in Mathematica to find the local maxima of a set of points? Suppose you have points={{xa,ya},{xb,yb},{xc,yc}...} peakQ[{{x1_,y1_},{x2_,y2_},{x3_,y3_}}] := Abs[y1] > Abs[y2] && Abs[y2] < Abs[y3]; peaks=Map[#[[2]]&, Select[Partition[points,3,1],peakQ[#]&]] Is it correct becau...

You probably might get better results if you apply some sort of smoother such as moving average/Savitsky-Golay filter or maybe try using a Kalman filter...
 
I was thinking of using a filter
but I have bad experiences applying a filter to experimental data
I applied a Savitsky-Golay filter to some data containing abrupt transitions (a velocity graph of a bouncing ball)
and it introduced some artifacts around the bounces, which I initially through were actually useful information.
it was quite something when we realized that the "interesting phenomena" we were seeing were simply artifacts :)
 
@VincentTjeng Maybe ping Oleksandr about it when he's around... he might have a thing or two to say about Savitsky-Golay on experimental data
I'm off for now...
Bye
 
okay! thanks again :)
 
7:31 AM
@rm-rf You may be thinking of this, or the related and more recent range specification post, or you may be recalling Leonid's method.
 
8:23 AM
Can anybody help me on optimizing this Mathematica code (mathematica.stackexchange.com/questions/23757/…) ?
 
8:37 AM
Is there a way to pass a slot unevaluated to the next &?

My example is as follows:
test = Range[#] & /@ Range[10];
ListPlot[test[[#]]] & /@ Range@Length[test]

What I'd like to do is to replace `test` by a slot - perhaps something like Hold could work?
I'm reading the documentation on slot and it seems like it isnt possible.
 
@VincentTjeng What's your actual problem?
 
I don't mean to self-promote my question
extremaPosition =
Flatten@Position[
Map[#, Partition[valueList, 2*aroundRange + 1, 1, {-(1 + aroundRange), 1 + aroundRange}, {}]] - valueList, 0.] &;
I had to use named variables
while I'm fine with doing it in this case as I needed to document the code, I was wondering whether you could replace (in this case) valueList with a #
 
8:54 AM
@VincentTjeng It doesn't look like promotion, since it's asked for and relevant. ;)
Anyway...
@VincentTjeng You could use #1, #2, #3 here, of course. Whether you should, for the sake of things like readability, is up to you.
 
okay
i'll try to come up with a better example - I often face these kind of problems in my coding, but the example i just quoted doesn't emphasize the issue
 
 
4 hours later…
1:03 PM
Feck, I'm feeling very uncharitable today...
 
1:24 PM
huh. surprising... the image is uploaded in the question body, but either I can't see it or he uploaded a white image
@Mr.Wizard The first one, definitely. Thanks :)
 
Good morning @rm-rf
 
Good morning :)
 
Morning mod people
 
1:40 PM
@bel, thanks, but I was hoping he'd do it himself...
(...and good morning to the ones in North/South America...)
 
(Brb, I'll go tell my neighbours you said good morning)
 
1:58 PM
@J.M. I know, but as I saw it he wasn't getting it
 
Good morning
Hi @Rojo
 
(good ol' days when we were like piranhas, closing and deleting crap left, right and center — even answers! lol)
 
2:17 PM
@rm-rf ...why can't we still be piranhas? We've graduated already, dammit... :D
 
@J.M. I still am, to an extent (belisarius feels most of the bites)... just not on answers anymore :P
we need more!
upvote everybody to 20k! Surely nothing can go wrong... :D
 
@rm-rf I wanna see a meta.SO where everybody automagically has 20k rep. >:)
 
Meta.SO is where you send poor ideas to die
 
2:44 PM
@rm-rf I had a cousin like that many years ago
@rm-rf We hold a tribal council and decided to impale him
 
 
1 hour later…
3:57 PM
I'm wishing for a ParallelCombine like Table: do not pregenerate the input, use an iterator instead
 
 
3 hours later…
7:23 PM
Wanted to comment on this, but ended up writing too an opinionated rant:
0
Q: Teaching Plan for High School Students

Joanna LirianoI would like to eventually teach Mathematica to my future high school students. In high school, there are many students who haven't taken a computer science class yet. I know Mathematica can get really complicated(it was for my first year!), what are some things that I should include in my lesso...

Probably I have a bit different idea than the question author of what constitutes "computer science."
... and even more so, what constitutes as studying it.
 
acl
8:24 PM
@kirma what did the rant say, then?
 
@acl The unpublished rant. Well, that it takes maybe a bit too much rigour and effort to use Mma to teach CS. But that implied the view of CS as a field of study that every student is expected to continue for years full time for a profession... I guess that's not exactly the thing (s?)he was asking about.
That question sounded to me like someone asking "how do you teach computational genomics algorithms to high school students" when what is meant is really "genetics for high school students" :)
I don't have a faintest idea what "CS for high school students" might mean. Back when I went to something equal to high school, it was "automatic data processing" (or "computers"), and definitely not full of formalisms, algorithms, data structures, compiler theory and stuff. So, Mma could actually be a reasonable tool for experimentation.
 
acl
9:00 PM
@kirma I see. This sounds like Szabolcs' comment/question
I had the same
I think all she meant with "haven't taken a CS class" here is "have had no contact with programming"
 
9:36 PM
:)
 
10:07 PM
Hey folks, I have seen a number of elegant answers using the commands Sow[] and Reap[], but even after I read the help file I don't really understand these commands and how they can be so useful. Anyone know if there are tutorials out there dealing with this specifically?
 
@KevinDriscoll Have you seen tutorial/CollectingExpressionsDuringEvaluation?
 
10:26 PM
no I had not, I'll check it out
 
 
1 hour later…
11:38 PM
@acl FWIW, I haven't ever taken a CS class either...
 
acl
11:59 PM
@J.M. neither have I :)
 

« first day (461 days earlier)      last day (4029 days later) »