# Tag Info

15

Start data First let us get some images. I am going to use the MNIST dataset for clarity. (And because I experimented with similar data some time ago.) MNISTdigits = ExampleData[{"MachineLearning", "MNIST"}, "TestData"]; testImages = RandomSample[Cases[MNISTdigits, (im_ -> 0) :> im], 100] Let us convince ourselves that all images have the same ...

11

Here is a very short solution: qf = a x^2 + b y^2 + c z^2 + 2 d x y + 2 e x z + 2 f y z; 1/2 D[qf, {{x, y, z}, 2}] (* ==> {{a, d, e}, {d, b, f}, {e, f, c}} *) This is just an application of the answer to Quick Hessian matrix and gradient calculation.

11

You can use Reduce[] to find a set of all conditions as follows: A = {{-1, 1, -1, 0, 0, 0}, {1, 0, 0, -1, -1, 0}, {0, -1, 0, 0, 1, -1}, {0, 0, 1, 1, 0, 1}}; b = {b1, b2, b3, b4}; x = {x1, x2, x3, x4, x5, x6} allConditions=Reduce[A.x == b, x] This returns b1 == -b2 - b3 - b4 && x3 == b2 + b3 + b4 - x1 + x2 && x5 == -b2 + x1 - x4 ...

10

First answer (extended comment actually) You have to define better your objective function. For example, the following works: ClearAll[mat, minev] SeedRandom[1] rm = RandomInteger[10, {40, 40, 3}]; mat[t_] := N[rm.{1, t, t^2}]; minev[t_?NumericQ] := First@Eigenvalues[mat[t], -1]; Take[Table[minev[t], {t, 0, 1, .01}], 3] (* {-0.864071 - 1.30548 I, ...

10

I think you need CoefficientArrays: mat = Last@CoefficientArrays[qf, {x, y, z}, "Symmetric"->True]; {x, y, z}.mat.{x, y, z} == qf // Simplify (* True *)

10

As requested by Anton. I halved the amount of noise because otherwise some images have barely any signal left. As you can see below, we are still putting in a significant amount of noise. (To conserve space I'm only visualizing the first ten images in this answer, but the denoising is happening over all 100 test images.) SeedRandom[2016] (* for ...

9

If you have Mathematica 10.3 or above you can use DistanceMatrix: DistanceMatrix[dataset2, DistanceFunction -> NormalizedSquaredEuclideanDistance] I'm assuming the same data as defined by kglr, you have not given us an example. If you don't have Mathematica 10.3 there's still HierarchicalClustering`DistanceMatrix which is used in the same way.

7

With[{x = Array[x, Dimensions[mA]]}, Solve[mA .x - x. mB + mC == 0, Flatten@x]] Or With[{x = Array[x, Dimensions[mA]]}, x /. Solve[mA .x - x. mB + mC == 0, Flatten@x]] {{{3, 1}, {0, 3}}}

6

x[t_] = {a[t], b[t]} /. RSolve[{ a[t + 1] == r*a[t] + s*b[t], b[t + 1] == s*a[t] + r*b[t], a[0] == 30, b[0] == 5}, {a[t], b[t]}, t][[1]] Since 0 < s < r < 1 then 0 < r - s < 1 - s < 1 and for large t, (r -s)^t is approximately zero. x[t] /. (r - s)^t -> 0 i.e., a[t] ≈ b[t] for large t Plot[ Evaluate[{ x[t] ...

6

Here is a way that yields symmetric matrix (for this example you could just write it down): m=Module[{r = {x -> 1, y -> 2, z -> 3}, tu = Tuples[{x, y, z}, 2]}, Normal@SparseArray[(## /. r) -> Coefficient[qf, Times @@ ##]/(2 - Boole[#[[1]] === #[[2]]]) & /@ tu, {3, 3}]] yields: {{a, d, e}, {d, b, f}, {e, f, c}} Check: ...

5

Your cube file had a very large grid ( 117*117*130 = 1779570), and 2 million points is just far too many for testing a function. So I created cube files for the electron density and electrostatic potential for the molecule furan, using a much sparser grid (around 8000 grid points instead). Here they are: Density cube file Potential cube file Now that ...

5

The answer is as you suspect - when you evaluate Dot[m1, m2, m3, m4, m5, ......m1000] the process is something like this: Look at the input: Dot[m1, m2, m3, m4, m5, ......m1000] Evaluate the first matrix product, m12=m1.m2 Look at the input: Dot[m12, m3, m4, m5, ......m1000] Evaluate the first matrix product, m123=m12.m3 Look at the input: Dot[m123, m4, ...

5

dataset2 = RandomReal[1, {5, 7}]; (* this stands for dataset[[All,2;;]] in your case*) dataset2 // MatrixForm output = Outer[NormalizedSquaredEuclideanDistance, dataset2, dataset2, 1]; output // MatrixForm

5

This answer compares two dimension reduction techniques SVD and Non-Negative Matrix Factorization (NNMF) over a set of images with two different classes of signals (two digits below) produced by different generators and overlaid with different types of noise. Note that question states that the images have one class of signals: I have a stack of images ...

5

Picking up on Marius tip on Inner in the comments: Inner[Apply[#1, {#2}] &, {{a, b}, {c, d}}, {h, k}] And @ciao offered a better version in comments: Inner[#1[#2] &, {{a, b}, {c, d}}, {h, k}]

5

This could be done with a custom function for the first argument of Inner that treats a differently (it's just a more convenient form of expressing your original idea). For example, consider this: ClearAll[f]; f[a, x_] := a[x] f[x_, a] := a[x] f[x_, y_] := x y Now for your first example: Inner[f, {{a, b}, {c, d}}, {h, k}] (* {b k + a[h], c h + d k} *) ...

4

Reverse /@ Partition[ {c1, c2, c3, c0}, 4, 1, {1, 1}, {c1, c2, c3, c0}] Edit or more simple : Reverse /@ Partition[{c1, c2, c3, c0}, 4, 1, {1, 1}]

4

cm = ToeplitzMatrix[{c0, c1, c2, c3}, RotateRight[Reverse[{c0, c1, c2, c3}]]]; cm // MatrixForm

4

The way I remember it from my Linear Algebra class is like this: Clear[b]; A = {{-1, 1, -1, 0, 0, 0}, {1, 0, 0, -1, -1, 0}, {0, -1, 0, 0, 1, -1}, {0, 0, 1, 1, 0, 1}}; bb = Array[b, Length@A]; Thread[NullSpace@Transpose@A . bb == 0] (* {b[1] + b[2] + b[3] + b[4] == 0} *) That is, the condition for a solution to A.x == b to exist is that b be in the ...

4

Thanks to MarcoB's pointer, I realized the following properties of conjugating one of the numbered Pauli matrices by $A$, $B$, or $C$. Table[ConjugateTranspose[PauliMatrix[i]] == PauliMatrix["A"].PauliMatrix[i].MatrixPower[PauliMatrix["A"], -1], {i, 3}] Table[-Transpose[PauliMatrix[i]] == PauliMatrix["B"].PauliMatrix[i].MatrixPower[PauliMatrix["B"], ...

3

Do you really need to use ToeplitzMatrix? What about following? MatrixForm@Transpose@NestList[RotateRight, #, Length[#]-1] &@{1, 2, 3, 4}

3

RandomVariate takes the option WorkingPrecision. Any residual artifact can be removed with Chop. testvector = RandomVariate[NormalDistribution[], 5, WorkingPrecision -> 20]; testunitvector = UnitVector[5, 1]; basisrotation = Transpose[RotationMatrix[{testunitvector, testvector}]]; Note that I corrected typo in definition of basisrotation output = ...

3

The way to answer this generically is via eigenvalues. Set up your matrix and take its eigenvalues: mat = {{r, s}, {s, r}}; Eigenvalues[mat] {r - s, r + s} If either r-s or r+s is greater than 1 (in magnitude) then the system will be unstable. If both are less than one, it will decay to zero. For your values r=0.8 and s=0.32, you have instability, which ...

3

f1 = Partition[# @@@ Tuples[Range[0, #2], #2 + 1], (#2 + 1)^2] &; m1 = f1[H, 3]; Use ReplaceAll m2 = m1 /. H[i_, j_, k_, l_] /; (i > j || k > l) :> Sequence[] /. H[i_, i_, k_, l_] :> H[i, i, k, l]/2 /. {} -> Style[0, Red]; Or DeleteCases m2b = DeleteCases[m1, H[i_, j_, k_, l_] /; (i > j || k > l), 2] /. ...

3

ClearAll[mat, minev] SeedRandom[1] rm = RandomInteger[10, {400, 400, 3}]; mat[t_] := rm.{1, t, t^2}; minev[t_?NumericQ] := Eigenvalues[mat[t], -1]; DiscretePlot[Evaluate[minev[t]], {t, 0, 1, .01}]

3

Clear[arrayH] arrayH[n_Integer] := Partition[ Flatten[Array[H, {n + 1, n + 1, n + 1, n + 1}, {0, 0, 0, 0}]], (n + 1)^2 ] arrayH[3] Then define an appropriate function H that calculates the value of each item using the indices. By way of example, if you had defined a function: Clear[H] H[i_, j_, k_, l_] := StringJoin @@ (ToString /@ {i, j, k, l}) ...

3

mat = RandomInteger[{0, 1}, {5, 10}]; v = RandomInteger[{100, 110}, 5]; (mat1 = Join[List /@ v, mat, 2]) // MatrixForm ds=Dataset[mat1] colnames=CharacterRange["a","z"][[;;11]]; ds2=Dataset[AssociationThread[colnames->#]&/@mat1]

3

Array size/shape agnostic, takes care of edge cases automagically, call with player identifier, position, and current array, returns changed array: fn = With[{cv = #1, cp = #2, cm = #3}, ReplacePart[cm, Select[Position[cm, cv], ChessboardDistance[#, cp] <= 1 &] -> 0]] &; Use example: fn[a, {5, 3}, mat]

3

The numerical definitions you give later modify the calculation of the symbolic definitions you use earlier. If you clear all your variables at the start of your calculation, the problem goes away and repeatable results are obtained. In particular, it is the numerical definition of k that seems to muddy the waters. In order to do what you want, a far better ...

3

You can export as a MATLAB .mat file if your array has less than 4 dimensions, rand = RandomReal[1, {1000, 3, 3}]; Dimensions@rand rand[[454, 1, 2]] Export["random.mat", rand]; (* {1000, 3, 3} *) (* 0.786307 *) When you import it again, you have the same dimensions and the elements are the same rand2 = Import["random.mat"]; Dimensions@rand2 rand2[[454, ...

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