Tag Info

New answers tagged

0

If I've got you right ** and the underscore in my_points are errors, rather than intensions. Assuming that let us define a function just to give an example: f[x_, y_, z_] := z*Exp[x*y]; and a list of points: pp = {{1, 0, 0}, {0, 0, 1}, {1, 1, 1}, {a, b, c}}; Your points are too complex, for the purposes of testing the list ppwill do. Let us try: ...


3

Yet another approach. data = {1, 3, 4, 6, 8, 0, 11, 12, 0, 13}; filterF[{a_, b_, c_} /; b == 0] := (a + c)/2 filterF[{a_, b_, c_}] := b fiter[data_] := Join[{data[[1]]}, filterF /@ Partition[data, 3, 1], {data[[-1]]}] fiter @ data {1, 3, 4, 6, 8, 19/2, 11, 12, 25/2, 13}


6

Here are two possibilities. First, use MovingMap: ClearAll[av]; av[{l_, 0, r_}] := (l + r)/2; av[{_, m_, _}] := m; and then smoothMM[list_] := Join[{First@list}, MovingMap[av, list, 3], {Last@list}] or, you can use in-place assignments: smooth2[list_] := Module[{copy = list, pos = Flatten[Position[list[[2 ;; -2]], 0]] + 1 }, copy[[pos]] = ...


7

This duplicates the behavior of yours (no effect on zeroes at ends): smoothee=ReplacePart[#, i_ /; i > 1 && i < Length@# && #[[i]] == 0 :> Mean[{#[[i - 1]], #[[i + 1]]}]] &; smoothee[{0, 1, 3, 4, 6, 8, 0, 11, 12, 0, 13, 0}] (* {0, 1, 3, 4, 6, 8, 19/2, 11, 12, 25/2, 13, 0} *) Here's a goofy ...


2

Also: g1 = {EdgeForm@Black,LightGray,Opacity@.1, CountryData[#, "Polygon"]&/@ CountryData["SouthAmerica"]}; DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}, ColorFunction -> "SunsetColors", Frame -> None, Epilog -> Inset@Graphics@g1] Answering your request, using your latitude and longitude: coords = List @@ ...


1

Assuming your map is a ContourPlot[] and your geopotential thing is a Plot3D[]. I think something like the following example could work: one = ContourPlot[Sin[x] Sin[y], {x, 0, 2 Pi}, {y, 0, 2 Pi}, ContourShading -> None] two = DensityPlot[Sin[x] Sin[y], {x, 0, 2 Pi}, {y, 0, 2 Pi}] Show[{two,one}] If your data for the pressure/geopotential is a list ...


1

Try this: Dataset@MapThread[ Append, {Normal[ds], Association["age" -> #] & /@ ages}] yielding the following: Have fun!


5

ds[MapIndexed[Append[#1, "age" -> ages[[First@#2]]] &]] {<|"name" -> "bob", "age" -> 1|>, <|"name" -> "joe", "age" -> 2|>} Note 10.0.2 throws a warning - who knows what's going on in that private type system: First::normal: Nonatomic expression expected at position 1 in \ First[TypeSystem`ZSignatures`PackagePrivate`i] ...


1

Some random test set: n = 1000; list1 = RandomInteger[1000, n]; list2 = RandomInteger[1000, n]; You can select elements with Select and Fuction res1 = Function[{x}, Select[list1, # < x &]] /@ list2; // AbsoluteTiming (* {0.988713, Null} *) There is similar function Cases, which looks better here res2 = Cases[list1, x_ /; x < #] & /@ ...


2

Map[Function[a, Select[list1, (#) < a &]], list2]


2

f[x_] = Sqrt[1 + x]; The fixed point is the golden ratio, independent of the starting value (x /. Solve[x == f[x], x][[1]]) == GoldenRatio True GoldenRatio == f[GoldenRatio] // FullSimplify True FixedPoint[f, {.01, .1, 1., 1.1, 10.}] // Union {1.61803} %[[1]] // RootApproximant 1/2 (1 + Sqrt[5]) % == GoldenRatio True



Top 50 recent answers are included