# Tag Info

7

"Reflected" padding works as desired but "Periodic" padding is missed. There is corresponding definition for "Reflected" RandomProcessesTemporalDataUtilitiesDumptoCannonicalPadding[ RandomProcessesTemporalDataUtilitiesDumptd_, "Reflected", RandomProcessesTemporalDataUtilitiesDumpw_, RandomProcessesTemporalDataUtilitiesDumpCaller_] := ...

7

Here is one way: movingMapCircular[f_, l_List] := MapThread[f@* List, {l, RotateLeft[l]}]; For example: movingMapCircular[f, {1, 2, 3, 4}] (* {f[{1, 2}], f[{2, 3}], f[{3, 4}], f[{4, 1}]} *) A generalization of this approach for arbitrary window size may look like: ClearAll[movingMapCircular]; movingMapCircular[f_, l_List, {n_Integer}] := MapThread[ ...

7

I would use the following, Quiet[ Check[ PowerMod[#, -1, 126] + #, ##&[], PowerMod::ninv ]& /@ Range[125], PowerMod::ninv ] (* {2, 106, 34, 110, 106, 92, 34, 146, 142, 92, 146, 124, 128, 106, 160, 110, 106, 92, 160, 146, 142, 92, 146, 124, 128, 106, 160, 110, 106, 218, 160, 146, 142, 218, 146, 250} *) where ##&[] inserts a ...

6

Since version 9 you do not need to do anything extra. tab1 = {{a1, a1 + a2}, {b1, b2*b2}} tab2 = {{2, 5}, {5, 2}} Solve[tab1 == tab2] {{a2 -> 3, b1 -> 5, a1 -> 2, b2 -> -Sqrt[2]}, {a2 -> 3, b1 -> 5, a1 -> 2, b2 -> Sqrt[2]}}

3

Leaving your first part unchanged Remove["Global`*"] firstline = {1, 2, 3, 2, 7}; secondline = {4, 3, 2, 5, 7}; typeOfEndCondition = 0; cc = {3, 2}; In the second part of your code there is only a ; missing after the Print function: avald1 = Table[{}, {i, 5}]; For[i = 1, i <= Length[cc], i++, If[typeOfEndCondition == 0, conline = ...

3

You can use MapThread for this purpose: eqs = MapThread[Equal, {tab1, tab2}, 2] (*{{a1 == 2, a1 + a2 == 5}, {b1 == 5, b2^2 == 2}}*) Solve[Flatten[eqs]] (*{{a2 -> 3, b1 -> 5, a1 -> 2, b2 -> -Sqrt[2]}, {a2 -> 3, b1 -> 5, a1 -> 2, b2 -> Sqrt[2]}}*)

3

Histograms can be generated within the dataset using AssociationMap: icds[ GroupBy[Floor[#"parameter"] &] /* AssociationMap[#[[1]] -> SmoothHistogram[#[[2]], PlotLabel -> #[[1]]] &] , All , "response" ] If desired, the histograms can be extracted from the dataset by adding an additional ascending operator to convert the association's ...

2

Outer and Tuples may be helpful, e.g. l1 = {1, 2, 3} l2 = {4, 5, 6, 7} Total /@ Tuples[{l1, l2}] Join @@ Outer[Plus, l1, l2] yields:{5, 6, 7, 8, 6, 7, 8, 9, 7, 8, 9, 10} or symbolically, Join @@ Outer[Plus, {a, b, c}, {d, e, f, g, h}] gives: {a + d, a + e, a + f, a + g, a + h, b + d, b + e, b + f, b + g, b + h, c + d, c + e, c + f, c + g, c + h}

2

The point is that List has the special property that the head doesn't disappear even with one element. So the solution (as belisarius noted in the comment) is to make the code generate expr with Head=List instead of Plus i.e, expr = List[a[i],b[i],c[i],d[i]] Then I can safely pass this to Map as in Map[f, expr], and it doesn't matter how many elements f ...

1

You can use Select if you are willing to modify your function slightly: Select[lis, (Function[{x, y}, #][2, 2] == 4) &] (*{x + y, x y}*)

1

list = {x - y, x + y, x*y}; Using a different test function, that tests for the equality and accepts the equality value as a parameter: testFun[{a_, b_, c_}] := (# /. {x -> a, y -> b}) == c &; testList = {{2, 2, 4}, {2, 0, 2}}; (* {2, 2, 4} means f[2,2] == 4, and {2, 0, 2} means f[2,0] == 2 *) You can either Map over list, returning the ...

1

Not sure if this would this would achieve what you described (I haven't been using MMA as much as I would like so my answer might be clumsy): Clear[countSameLetters] countSameLetters[list_List, distance_Integer] := Position[ Flatten@Differences@Position[list, #] & /@ CharacterRange["a", "z"], distance] // Length To display each distance with ...

1

comp[a_, b___, c_] := a == c k[list_, dist_] := Count[ListConvolve[SparseArray[{1 -> 1, # -> 1}, #]&[dist+1], list, {-1, 1}, 0, Times, comp], True] list = {d, a, e, a, e, b, e, b, c, d, d}; k[list, #] & /@ Range[Length[list] - 1] (* {1, 4, 0, 1, 0, 0, 0, 0, 1, 1} *)

1

data = {{a, b}, {c, d}, {e, f}}; ClearAll[foo, f1, f2, f3]; f1 = MapAt[Divide[Plus @@ foo /@ {##}, foo@#] & @@ # &,Transpose[{#[[All, 1]], #}], {{All, 2}}] &; f2 = MapAt[Divide[Plus@##, #] &@@ # &, Transpose[{#[[All, 1]], Map[foo, #, {-1}]}], {{All, 2}}] &; f3 = {#1, (foo[#] + foo[#2])/foo[#]} & @@@ # &; f1 @ data == f2 @ ...

Only top voted, non community-wiki answers of a minimum length are eligible