Tag Info

New answers tagged

3

Here is a Fourier Basis approach: ClearAll[FourierBasis2D]; FourierBasis2D[{numx_, numy_}, {λx_, λy_}, x_, y_] := N[With[{ωn = 2 π/λx, ωm = 2 π/λy}, Flatten[ {1}~Join~ Table[ {Cos[ n ωn x] Cos[m ωm y], Cos[ n ωn x] Sin[ m ωm y], Sin[ n ωn x] Cos[m ωm y], Sin[ n ωn x] Sin[ m ωm y]}, {n, numx}, {m, ...


0

You can use ListPlot3D and its InterpolationOrder option. That has built in smoothing. ListPlot3D[points, InterpolationOrder->3] This will give you a cubic interpolation. Close to what you are looking for and built into Mma. EDIT: Well, if the points are evenly spaced which they appear to be. But if not then no as this will not produce a scatter ...


1

The option "ExtrapolationHandler" -> function can be used to control extrapolation. The setting "ExtrapolationHandler" -> {Indeterminate &} causes Indeterminate to be the value of the interpolation for inputs outside the domain. One can turn off the warning message, too, as done below. myfcn = Interpolation[ Table[{x, 2 x^3 - 5 x^4/3 + 5 ...


2

As already said in my comment, in newer version of Mathematica you can simply restrict your interpolating function. If ContourPlot gets a non-numeric result, it will ignore it. A simple example is With[{ip = Interpolation[{1, 4, 5, 7, 9}]}, func[x_ /; 1 <= x <= 5] := ip[x] ] ContourPlot[func[x t] == x, {t, 0, 2}, {x, 0, 8}] I'm not sure ...


0

It's not clear to me whether you're looking for general insight into this data or to develop specific analytical queries. But here's a barebones forest-for-the-trees graphical overview of the state changes which you could use to refine your questions, such as what metrics are relevant (eg median time to close a ticket vs number of times it's still open in ...


4

I would probably write this Interpolation[AList[[All, {1, 2, #}]], InterpolationOrder -> 1] & /@ Range[3, maxN + 3] It's probably a little bit faster than what you have. BTW it looks in your example as if the header is not actually a part of AList, if it is you should remove it using Rest, i.e. Rest[Alist][[All...


1

Ok, here's an answer to my own question based on the paper by Cheng Hian Goh, et al. There doesn't seem to be any pre-canned data structure in mathematica that supports this, perhaps it's an enhancement request for the future. Therefore this answer is really just my favorite solution so far (that doesn't involve round tripping to an external database). The ...


9

Major update, version 2.0 What changed: Is a different, more clever way of solving the problem. Overcomes most of the issues of previous versions. Problem summary: I will rephrase the problem in simplest terms. There exests a named curve called limacon (french, pronounced [ˈlɪməsɒn], means snail), described by a simple equation $r=a+b\cos{\theta}$ in ...


1

Use Part (mat = Array[a, {4, 7}]) // MatrixForm (mat12 = mat[[All, {1, 2}]]) // MatrixForm (mat13 = mat[[All, {1, 3}]]) // MatrixForm


1

Since you say picking up the columns is your only problem, I will assume you know how to import your data into Mathematica as an array and have it in this form. data = {{0., 0.00763266, 0.0157101, 0., -0.10003, 0.0485991, 0.}, {2., 0.00489483, 0.0167661, 0., -0.106755, 0.0311657, 0.}, {4., 0.00201832, 0.0173491, 0., -0.110466, 0.0128487, 0.}, ...


1

list = {{{1, 2, 3}, 10}, {{1, 2, 3}, 20}, {{1, 2, 4}, 30}}; result = GroupBy[list, First -> Last, Mean] Normal @ result /. Rule -> List OR Thread[{Keys @ #, Mean /@ Values @ #}] &[GroupBy[list, First -> Last]]


2

lis = GatherBy[{{{1, 2, 3}, 10}, {{1, 2, 3}, 20}, {{1, 2, 4}, 30}}, First]; Plus @@@ lis/Length /@ lis Plus @@ #/Length@# & /@ lis Plus[##]/Length@{##} & @@@ lis (*{{{1, 2, 3}, 15}, {{1, 2, 4}, 30}}*)


2

Just an approach with Reap and Sow. Probably not be efficient. data = {{{1, 2, 3}, 10}, {{1, 2, 3}, 20}, {{1, 2, 4}, 30}}; Last@Reap[Sow[#2, w[#1]] & @@@data, _, {ReplacePart[#1, 0 -> Identity], Mean@#2} &] yields: (*{{{1, 2, 3}, 15}, {{1, 2, 4}, 30}}*)


6

lst = {{{1, 2, 3}, 10}, {{1, 2, 3}, 20}, {{1, 2, 4}, 30}}; DeleteDuplicates[lst, First@#1 == First@#2 &] (* {{{1,2,3},10},{{1,2,4},30}} *) First /@ GatherBy[lst, First] (* {{{1,2,3},10},{{1,2,4},30}} *) {#[[1, 1]], Mean[#[[All, 2]]]} & /@ GatherBy[lst, First] (* or {#[[1, 1]], Mean[#[[All, 2]]]} & /@Gather[lst, First@#1 == First@#2 &] *) ...


13

DeleteDuplicatesBy may be faster if used as follows: DeleteDuplicatesBy[{{{1, 2, 3}, 10}, {{1, 2, 3}, 20}, {{1, 2, 4}, 30}}, First] {{{1, 2, 3}, 10}, {{1, 2, 4}, 30}} For your second need: lis = GatherBy[{{{1, 2, 3}, 10}, {{1, 2, 3}, 20}, {{1, 2, 4}, 30}}, First]; mean = Mean /@ Map[Last, lis, {2}]; Then: Transpose[{lis[[All, 1, 1]], mean}] ...


2

In version 9 you can use Part to access the parts of an InterpolatingFunction: points = {{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}}; ifun = Interpolation[points] (* InterpolatingFunction[{{0,5}},<>] *) {ifun[[3]], ifun[[4]]} (* {{{0,1,2,3,4,5}},{{0},{1},{3},{4},{3},{0}}} *) You can also access Properties of ifun using (not ifun["Properties"] ...



Top 50 recent answers are included