New answers tagged

1

Here's my attempt at fixing your code: mat = {{0, 1, 0, 0, 0}, {1, 0, 1, 0, 0}, {0, 1, 0, 1, 1}, {0, 0, 1, 0, 0}, {0, 0, 1, 0, 0}}; M = SparseArray[mat] sigmoid[x_] := 1/(1 + Exp[-x]) posList[n_] := Flatten[M[[n]]["NonzeroPositions"]] negList[n_] := Flatten[Position[Normal[M[[n]]], 0]] nextChoice[v_, t_, p_, q_] := Module[ {vpositive, ...


2

This is just a supplement to the excellent answer by b3m2a1. I will answer how to register an existing virtual environment in MMA. First install the package pyzmq in virtual environment. This package is required to run python in ExternalEvaluate (https://reference.wolfram.com/language/workflow/ConfigurePythonForExternalEvaluate.html). $ source venv/bin/...


1

Like this? g1[x_] = x*x + 1; g2[x_] = Log[x]; g3[x_] = 2 Cos[x]; funclist = "g" <> ToString[#] & /@ {1, 2, 3} // ToExpression; Plot[#[x] & /@ funclist, {x, -5, 5}] Better way: g[1][x_] = x*x + 1; g[2][x_] = Log[x]; Plot[g[#][x] & /@ {1, 2}, {x, -5, 5}] Actually, it's not recommended to do that in Python. eval is evil. You could ...


1

Clear["Global`*"] pltData = {{Sin[x], {0, 2 Pi}, {-1, 1}}, {y*Cos[y], {-2 Pi, 2 Pi}, {-6, 6}}, {{Sqrt[5^2 - x^2], -Sqrt[5^2 - x^2]}, {-5, 5}, {-5, 5}}, {{z^2 - z - 6}, {-3, 4}, Automatic}}; Column[Plot @@@ ({#[[1]], Insert[#[[2]], Variables[Level[#[[1]], {-1}]][[1]], 1], PlotRange -> #[[3]]} & /@ pltData)]


Top 50 recent answers are included