Community RSS Feed
http://community.wolfram.com
RSS Feed for Wolfram Community showing any discussions in tag Wolfram Scienceshowthread.php?threadid=399 sorted by active[GIF] Square and Triangle Curve Shortening Flows
http://community.wolfram.com/groups/-/m/t/1246571
A few months ago, the thread [Circle Morphing into a triangle][1] came up. This thread falls short of discussing curvature flows, including the famous curve shortening flow. This is an important topic, leading to the more general Ricci flow, [as discussed by Jim Isenberg on Numberfile.][2] The purpose of this thread is to elaborate upon the earlier calculations by deforming square and triangle elliptic curves into circles, while preserving the interior area. As discussed elsewhere, the circle solves [Dido's problem][3], to enclose maximum area by the least amount of cow's hide. Thus an area-preserving flow ending with a circle, by reverse logic, will usually be a *curve lengthening flow*. This can be proven rigorously for the two examples here by integrating the perimeter as a Fourier series expansion. Building upon the earlier humorous [Arrival thread][4], future posts may explore seemingly obvious connections between elliptic curves and Zen drawings, especially Sengai's drawing, sometimes called "Circle, Triangle, Square", as seen on the cover of ["The Zen Art Book"][5] . Additional information about these calculations will eventually be made available in the form of a more serious article.
## Curve Parameterizations and Areas ##
Quartic\[Phi]0 = ArcSin[Sqrt[4 \[Alpha] \[CapitalPhi]]]/2;
QuarticF[1] = 1/Sqrt[\[CapitalPhi]] Cos[Quartic\[Phi]0 - Pi/2];
QuarticF[2] = 1/Sqrt[\[CapitalPhi]] Cos[Quartic\[Phi]0];
Cubic\[Phi]0 = (2/3) ArcSin[3 Sqrt[3] x/2];
CubicF[n_] :=
Sqrt[\[Alpha]] Divide[1 + 2 Cos[Cubic\[Phi]0 - n 2 Pi/3], 3 x] /. {
x -> Sqrt[\[Alpha] ] \[CapitalPhi]}
A3 = \[Alpha] Hypergeometric2F1[1/3, 2/3, 2, 27 \[Alpha]/4];
A4 = \[Alpha] Hypergeometric2F1[1/2, 1/2, 2, \[Alpha]];
## Triangle Animation: "△ Grow And Flow △" ##
TriangleGrow = PolarPlot[{
1, Evaluate[
Sqrt[1/A3] CubicF[1] /. \[CapitalPhi] ->
Cos[3 \[Phi]] /. {\[Alpha] -> 4/27}], Evaluate[
Sqrt[1/A3 /. {\[Alpha] -> 4/27}] CubicF[1] /. \[CapitalPhi] ->
Cos[3 \[Phi]] /. {\[Alpha] -> #/1000 (4/27)}]}, {\[Phi], 0,
2 Pi}, PlotRange -> {{-2, 2}, {-2, 2}},
PlotStyle -> {Gray, Gray, Directive[Thick, Black]},
Axes -> False] & /@ (10 Range[0, 100]);
TriangleFlow = PolarPlot[{
1, Evaluate[
Sqrt[1/A3] CubicF[1] /. \[CapitalPhi] ->
Cos[3 \[Phi]] /. {\[Alpha] -> 4/27}], Evaluate[
Sqrt[1/A3] CubicF[1] /. \[CapitalPhi] ->
Cos[3 \[Phi]] /. {\[Alpha] -> #/1000 (1/27)}]}, {\[Phi], 0,
2 Pi},
PlotRange -> {{-2, 2}, {-2, 2}},
PlotStyle -> {Gray, Gray, Directive[Thick, Black]},
Axes -> False] & /@ Reverse[10 Range[400]];
TriangleFinal = PolarPlot[{
Evaluate[
Sqrt[1/A3] CubicF[1] /. \[CapitalPhi] ->
Cos[3 \[Phi]] /. {\[Alpha] -> 4/27}], 1}, {\[Phi], 0, 2 Pi},
PlotRange -> {{-2, 2}, {-2, 2}},
PlotStyle -> {Gray, Directive[Thick, Black]}, Axes -> False];
TriangleGrowFlow = Join[TriangleGrow, Table[TriangleGrow[[-1]], {100}],
TriangleFlow, Table[TriangleFinal, {100}]];
ListAnimate[TriangleGrowFlow];
![TriangleGrowFlow][6]
[Youtube Video][7]
## Square Animation: "□ Grow and Flow □" ##
SquareGrow = PolarPlot[{
1,
Evaluate[
Sqrt[1/A4] QuarticF[
1] /. \[CapitalPhi] -> (Cos[\[Phi]] Sin[\[Phi]])^2 /. {\
\[Alpha] -> 1}], Evaluate[
Sqrt[1/A4 /. {\[Alpha] -> 1}] QuarticF[
1] /. \[CapitalPhi] -> (Cos[\[Phi]] Sin[\[Phi]])^2 /. {\
\[Alpha] -> #/1000}]}, {\[Phi], 0, 2 Pi},
PlotRange -> {{-2, 2}, {-2, 2}},
PlotStyle -> {Gray, Gray, Directive[Thick, Black]},
Axes -> False] & /@ (10 Range[0, 100]) // Quiet;
SquareFlow = PolarPlot[{
1,
Evaluate[
Sqrt[1/A4] QuarticF[
1] /. \[CapitalPhi] -> (Cos[\[Phi]] Sin[\[Phi]])^2 /. {\
\[Alpha] -> 1}], Evaluate[
Sqrt[1/A4] QuarticF[
1] /. \[CapitalPhi] -> (Cos[\[Phi]] Sin[\[Phi]])^2 /. {\
\[Alpha] -> #/1000}]}, {\[Phi], 0, 2 Pi},
PlotRange -> {{-2, 2}, {-2, 2}},
PlotStyle -> {Gray, Gray, Directive[Thick, Black]},
Axes -> False] & /@ Reverse[10 Range[100]] // Quiet;
SquareFinal = PolarPlot[{
Evaluate[
Sqrt[1/A4] QuarticF[
1] /. \[CapitalPhi] -> (Cos[\[Phi]] Sin[\[Phi]])^2 /. {\
\[Alpha] -> 1}], 1}, {\[Phi], 0, 2 Pi},
PlotRange -> {{-2, 2}, {-2, 2}},
PlotStyle -> {Gray, Directive[Thick, Black]}, Axes -> False] //
Quiet;
SquareGrowFlow = Join[SquareGrow, Table[SquareGrow[[-1]], {100}],
SquareFlow, Table[SquareFinal, {100}]];
ListAnimate[SquareGrowFlow]
![Square Grow Flow][8]
[Youtube Video][9]
[1]: http://community.wolfram.com/groups/-/m/t/1215747
[2]: https://www.youtube.com/watch?v=hwOCqA9Xw6A
[3]: http://mathworld.wolfram.com/DidosProblem.html
[4]: http://community.wolfram.com/groups/-/m/t/1034626
[5]: https://books.google.com/books?id=5CbJhbj0nNYC&printsec=frontcover&dq=the%20art%20of%20zen&hl=en&sa=X&ved=0ahUKEwj_5oPc3IzYAhXq5oMKHVMhDQwQ6AEIQDAE#v=onepage&q=the%20art%20of%20zen&f=false
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=TriangleGrowFlow.gif&userId=234448
[7]: https://www.youtube.com/watch?v=7a5Sw4nAoiA
[8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=SquareGrowFlow.gif&userId=234448
[9]: https://www.youtube.com/watch?v=yEQ9j6Ub_RcBrad Klee2017-12-15T19:53:57ZDiscrete event simulation similar to Harel/UML statecharts
http://community.wolfram.com/groups/-/m/t/1246602
I use Mathematica to develop methods for formal model-based user interface evaluation. Most of the methods require creating a finite state machine (FSM) of an interface, where the states are states of the interface and the transitions are actions initiated by the user. If you think about a 4 function calculator, the actions are all of the buttons and the state contains the contents of the display plus any internal variables required to compute the next visible state, given any button press. One way to create the FSM is to define a function that takes a button and the current state and produces the next state. Starting with the initial state of the device, a tree search produces a complete FSM for the interface.
As I apply these methods to more complex interfaces, It seems easier and more efficient to first model interfaces using something like UML/Harel statecharts, then convert those charts to an FSMs. Statecharts contain abstractions that greatly reduce the number of states and also make fairly complex event-driven behavior less error prone to model/program.
After downloading the trial of SystemModeler and spending a few hours working with it, I cannot tell at all whether I can create the kinds of event-driven models that I need, or even how to go about doing this. Modelica's Stategraph library claims to have Harel statechart power, but the modelica documentation is rather poor and all of the examples in SystemModeler/Modelica seem to use time-based or equation-based transitions. In contrast, Harel/UML statecharts are based on events (such as "+ pressed"). In addiiton, transitions can raise events that are then processed throughout the chart. In one example, I have two pull down menus. Making a choice from the first does not affect the second, but making a choice in the second, sets the first to the same value. The statechart I've attached here is showing the model for one of these pull down menus. In this case, there are two orthogonal parts to the state: the menu is either open or closed and is simultaneously in one of the states shown on the right.
So my question is whether this is possible in SystemModeler and, if so, is it possible to find better documentation/examples on how to do it?
Second, it is possible to see the chart with the current state(s) highlighted as I send events to it? In the attached image, the yellow states are active and I can click events from an event list (not shown) to trigger the next event and state transition.
Right now, I'm using Yakindu statechart tools (the source of this image), because it is free to me, and allows graphical simulation while viewing the statechart. Yakindu can create Java code of the statechart that I can then access from MMA to build the FSM using depth-first search over the event and state space. Unfortunately, Yakindu is based on Eclipse and its user interface leaves a lot to be desired, plus I've not found a way to edit the textual descriptions of the model (which is often easier than using a GUI).
ToddTodd Johnson2017-12-15T19:38:03ZPurchase a home license for multiple machines?
http://community.wolfram.com/groups/-/m/t/1245266
Hi!
I have a laptop that I travel with and a desktop system at home that I use for heavy computation and driving various shop machines.
I want to purchase a license to Mathematica that will work on both. I would prefer to use my own mechanisms to sync between. Running two copies simultaneously is not desired at all; I just want to be able to travel and noodle, then pop to my home powerful desktop and compute.
It is totally, **bafflingly**, unclear if this is possible with any of the licenses offered. The product comparisons and online information as to what is included with each license or how they differ is confusing, lacking in information and poorly presented.
What is the best product for this need?Bill Bumgarner2017-12-14T22:55:29ZExport Association as a CSV file
http://community.wolfram.com/groups/-/m/t/1246360
For this question I use a simple example. I have the following association
test = Association[{a -> x, b -> y, c -> z}]
the output is: <|a -> x, b -> y, c -> z|>
After I export this association:
Export["test.csv", test, "CSV"]
I want to import the same file
Import["test.csv"]
the result is: {{"<|a -> x, b -> y, c -> z|>"}}
And this is a string.
What I want is a list like:
{{a,x},{b,y,{c,z}}.
What is the easist way to do this?Michiel van Mens2017-12-15T16:18:46ZComputing change in water level via processing of satellite images
http://community.wolfram.com/groups/-/m/t/1232351
Inspired by [Planet's][1] guide on [calculating change in water level][2], I wanted to re-create their visual analysis environment from within the Wolfram Language.
Using the Planet API
====================
The Planet API is easily leveraged from their quickstart python [here][3].
Browsing the [Planet Explorer][4] we can find some cool assets, note their names, and store to variables:
idList = {"20160804_180723_0e26", "20160820_180756_0e30"}; (*id of image*)
itemType = "PSScene4Band"; (*Type of satellite/image *)
assetType = "analytic"; (*analytic = cool multi spectrum image, visual = visible spectrum image*)
path = "images/"; (*where you want to output the images*)
The new `ExternalEvaluate` will allow us to write an easy wrapper to access the APIs functionality:
session=StartExternalSession[<|"System"->"Python","Version"->"2.7.12 :: Anaconda 4.2.0 (x86_64)", "ReturnType"->"String"|>];
(*change working directory and add the api key to the environment*)
ExternalEvaluate[session,"import os; os.chdir('/Users/peter/Downloads')"]
ExternalEvaluate[session,"os.environ['PLANET_API_KEY'] = "~~PersistentValue["PLANETAPIKEY"]]
(*overload an uninitialized global reference*)
ExternalEvaluate[session,
"class dummy:
download = 'downloading images'"]
ExternalEvaluate[session, "args = dummy()"]
(*Load full download script, downloaded from *)
ExternalEvaluate[session,File["/Users/peterro/Downloads/download.py" ]]
convertToJSON[strAr_] := ExportString[strAr,"JSON", "Compact"->True];
inputArgs = <|"idList"->idList,"itemType"-> itemType, "assetType"->assetType |>;
activateArgs = Join[inputArgs,<|"activateOrCheck"->"activate"|>];
checkArgs = Join[inputArgs,<|"activateOrCheck"->"activate"|>];
downloadArgs = Join[inputArgs,<|"path"->path|>];
processActivation = StringTemplate["process_activation(activate, `idList`, `itemType`, `assetType`, `activateOrCheck`)"];
processDownload = StringTemplate["process_download(`path`, `idList`, `itemType`, `assetType`, '')"];
(*activate the assets*)
ExternalEvaluate[session,processActivation[convertToJSON /@ activateArgs]];
obj=SessionSubmit[ScheduledTask[
(*check if the assets are active*)
If[ImportString[Last@StringSplit[ExternalEvaluate[session,processActivation[convertToJSON /@ checkArgs]],"\n"]] != "[True, True]" ,
Module[{},
Print["Assets active, downloading"];
TaskRemove[$CurrentTask];
(*download the assets*)
Print[ExternalEvaluate[session,processDownload[convertToJSON /@ downloadArgs]]];
DeleteObject[session];
Print["Download Complete"];
]
,
Print["Waiting for download: " ~~ DateString[]]
],{10,10}]];
This will asynchronously download the images from the Planet servers when they are prepared for download.
## Process the Images ##
Import:
img820 = ImageResize[First@Import["20160820_180756_0e30_analytic.tif"], Scaled[.4]];
img804 = ImageResize[First@Import["20160804_180723_0e26_analytic.tif"], Scaled[.4]];
![Initial Import][5]
These look weird because we're viewing the stacked {R,G,B,IR} channels. For the purposes of calculating water level change, I wanted to use the IR channel:
infra820 = ImageAdjust[ColorCombine[ColorSeparate[img820][[{4}]]]];
infra804 = ImageAdjust[ColorCombine[ColorSeparate[img804][[{4}]]]];
![IR chan adjusted][6]
Next, we'll binarize the image using thresholds derived from the image histogram:
![img histogram][7]
binarized820 = MorphologicalBinarize[infra820, {0.172, 0.896}];
binarized804 = MorphologicalBinarize[infra804, {0.172, 0.896}];
![binarized][8]
These images are hard to work with because they are rotated and not cropped so we can use some [cool image rotation][9] to correct that
First identify the lines:
lines820=ImageLines[GradientFilter[binarized820,1], MaxFeatures->5];
lines804=ImageLines[GradientFilter[binarized804,1], MaxFeatures->5];
Show[#,ImageSize->Large]&/@ {HighlightImage[binarized820,{Orange,Line/@lines}],HighlightImage[binarized804,{Orange,Line/@lines2}]}
![bin with lines][10]
Rotate and crop:
rotateCrop820 = ColorNegate@ImagePad[ImageCrop[ImageRotate[binarized820,Median[Select[-ArcTan[(#[[2,2]]-#[[1,2]])/(#[[2,1]]-#[[1,1]])]&/@
ImageLines[GradientFilter[binarized820,1]],#<20/360 2 \[Pi]&&#>-20/360 2 \[Pi]&]]]],-20]
![rotated and cropped 820][11]
Next we'll use the overlapping key points to create a comparable area between the two images:
crops= { rotateCrop804,rotateCrop820};
matches = ImageCorrespondingPoints[Sequence@@crops, KeypointStrength->.01] ;
{matches804,matches820} = matches;
Column@MapThread[Show[#1,Graphics[{Blue,MapIndexed[Inset[#2[[1]],#1]& ,#2]}], ImageSize->Large]&,{crops,matches}]
![labels][12]
Use the bounding regions to create the masks:
![bounding region][13]
Tie it all together and measure the change in water level
waterPixels820 = Total@Flatten@ImageData@ImageTrim[rotateCrop820,Round /@ BoundingRegion[matches820] /. Cuboid->List]
waterPixels804 = Total@Flatten@ImageData@ImageTrim[rotateCrop804,Round /@ BoundingRegion[matches804] /. Cuboid->List]
We get **575304** and **597415** meaning the water level decreased by **3.7%** over these days.
[1]: https://www.planet.com/
[2]: https://www.planet.com/docs/guides/quickstart-water_level_change/
[3]: https://www.planet.com/docs/api-quickstart-examples/examples/download.py
[4]: http://https%20:%20//%20www.planet.com/explorer/
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-27at7.20.28PM.png&userId=1231150
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-27at7.23.59PM.png&userId=1231150
[7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-27at7.25.55PM.png&userId=1231150
[8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-27at7.28.42PM.png&userId=1231150
[9]: https://mathematica.stackexchange.com/questions/152445
[10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-27at7.31.59PM.png&userId=1231150
[11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-27at7.34.30PM.png&userId=1231150
[12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-27at7.39.14PM.png&userId=1231150
[13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-27at7.41.08PM.png&userId=1231150Peter Roberge2017-11-28T03:53:48ZPack NonConvex Curve Into An Ellipse
http://community.wolfram.com/groups/-/m/t/1242150
Set Up Functions Describing Ellipse and Cassini Oval
rule to translate and rotate coordinates
rottransrl[{xc_, yc_, \[Theta]_}, {x_, y_}] =
Thread[{x, y} -> RotationMatrix[-\[Theta]].{x - xc, y - yc}];
function describing an ellipse with axes {a,b}, center {xc,yc} and orientation \[Theta]
ell[{a_, b_}, {xc_, yc_, \[Theta]_}] = (x/a)^2 + (y/b)^2 - 1 /.
rottransrl[{xc, yc, \[Theta]}, {x, y}];
function describing a Cassini oval with axes {a,b}, center {xc,yc} and orientation \[Theta]
oval[{a_, b_}, {xc_, yc_, \[Theta]_}] = ((x - a)^2 + y^2) ((x + a)^2 + y^2) -
b^4 /. rottransrl[{xc, yc, \[Theta]}, {x, y}];
Generate Regions for Elllipse and Cassini Oval
ellipse region with axes {a,b}, center {xc,yc} and orientation \[Theta]
el = ImplicitRegion[ell[{a, b}, {xc, yc, \[Theta]}] <= 0, {x, y}];
Cassini oval region with axes {1,5/4}, centered at {1/7,0} and rotated by \[Pi]/10
ov = ImplicitRegion[oval[{1, 5/4}, {1/7, 0, \[Pi]/10}] <= 0, {x, y}];
Attempt to find smallest area ellipse with oval contained in it, Using RegionWithin and NMinimze
TimeConstrained[
sln = NMinimize[{a*b, RegionWithin[el, ov], a >= 0, b >= 0}, {a, b, xc,
yc, \[Theta]}, Method -> {"NelderMead", "PostProcess" -> False}], 360]
$Aborted
Reformulate Problem Using Lagrange Multipliers
function to generate Lagrange multiplier equations for finding extreme values for function describing curve1 for points on curve2.
curveWithinLagMults[curve1_, curve2_, vars_List] :=
Join[Thread[D[curve1 == \[Lambda]*curve2, {vars}]], {curve2 == 0,
curve1 == r}]
use NSolve to find the solutions to the Lagrange multiplier equations
curveWithinNSolve[curve1_, curve2_, vars_List] :=
NSolve[curveWithinLagMults[curve1, curve2, vars], Join[vars, {\[Lambda], r}],
Reals]
function to find the maximum value of ellipse function for points on the Cassini oval
f[a_?NumericQ, b_?NumericQ, xc_?NumericQ, yc_?NumericQ, \[Theta]_?NumericQ] :=
Max[r /. curveWithinNSolve[ell[{a, b}, {xc, yc, \[Theta]}],
oval[{1, 5/4}, {1/7, 0, \[Pi]/10}], {x, y}]]
find the minimum area ellipse containing the Cassini oval
AbsoluteTiming[
sln = NMinimize[{a*b, f[a, b, xc, yc, \[Theta]] <= 0, a >= 0, b >= 0}, {a, b,
xc, yc, \[Theta]}, Method -> {"NelderMead", "PostProcess" -> False}]]
NMinimize::incst: NMinimize was unable to generate any initial points satisfying the inequality constraints {f[a,b,xc,yc,\[Theta]]<=0}. The initial region specified may not contain any feasible points. Changing the initial region or specifying explicit initial points may provide a better solution.
NMinimize::nosat: Obtained solution does not satisfy the following constraints within Tolerance -> 0.001`: {f[a,b,xc,yc,\[Theta]]<=0}.
{95.9544, {1.61441, {a -> 1.62478, b -> 0.993618, xc -> 0.145382,
yc -> -0.000172813, \[Theta] -> 0.305791}}}
plot the result
p = ContourPlot[{oval[{1, 5/4}, {1/7, 0, \[Pi]/10}] ==
0, (ell[{a, b}, {xc, yc, \[Theta]}] /. sln[[2]]) == 0}, {x, -2,
2}, {y, -2, 2}, ImageSize -> Small];
find the extremum points
pts = curveWithinNSolve[(ell[{a, b}, {xc, yc, \[Theta]}] /. sln[[2]]),
oval[{1, 5/4}, {1/7, 0, \[Pi]/10}], {x, y}]
{{x -> -1.34479, y -> 0.0336357, \[Lambda] -> 0.155498,
r -> -0.0117827}, {x -> 1.63088, y -> -0.0328177, \[Lambda] -> 0.154844,
r -> -0.0186086}, {x -> -0.0933478, y -> 0.711853, \[Lambda] -> 0.324496,
r -> -0.428871}, {x -> 1.6821, y -> 0.433738, \[Lambda] -> 0.121384,
r -> -0.0326298}, {x -> -1.39363, y -> -0.445365, \[Lambda] -> 0.121615,
r -> -0.0267585}, {x -> 0.38161, y -> -0.711032, \[Lambda] -> 0.323676,
r -> -0.431725}, {x -> -1.01925, y -> -0.913277, \[Lambda] -> 0.161002,
r -> 0.00116534}, {x -> 1.29604, y -> 0.91782, \[Lambda] -> 0.162165,
r -> -0.00179309}}
show the result with the extremum points
Show[p, Graphics @ Point[{x, y} /. pts]]
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=cassini_oval_in_ellipse.jpg&userId=29126Frank Kampas2017-12-09T15:51:13ZFinding the Classifier Boundary Function For Method->LogisticRegression
http://community.wolfram.com/groups/-/m/t/1245216
Here' s a diagram we often see in machine learning. I want to construct something like it using the Wolfram Language and Classify, at least when the method is logistic regression. Here's how I go about it.
![Boundary Drawing][1]
Let' s generate some simple data.
SeedRandom[121217];
trainx = RandomReal[{0, 1}, {20, 2}];
trainy = Map[
If[LogisticSigmoid[{-2.7, 1.4}.# +
RandomVariate[NormalDistribution[0.3, 0.5]]] > 0.5, 1, 0] &,
trainx];
If our classification task does not require much complexity, we can use LogitModelFit and some algebra to find the boundary.
boundaryExpression[fm_FittedModel] :=
y /. Quiet@First@Solve[fm[x, y] == 1/2, y] // Expand;
boundaryExpression[lomf]
We find it is y=-3.69718 + 10.2671 x
We can now visualize the boundary and get a picture like the one above with the following code.
With[{be = boundaryExpression[lomf]},
Show[ListPlot[
KeySort[GroupBy[
MapThread[List, {trainx, trainy}], (ToString[Last[#]] &) ->
First]], PlotMarkers -> {{"-", 18}, {"+", 18}}, Axes -> False,
Frame -> True],
Plot[be, {x, 0, 1}, PlotStyle -> {Thick, Dashed, Black}]]
But all of that is using LogitModelFit. Sometimes we need regularization or other features of Classify. So, here's how we generate a similar picture using Classify.
cl = Classify[trainx -> trainy, Method -> {"LogisticRegression", "L1Regularization" -> 0,
"L2Regularization" -> 0}, TrainingProgressReporting -> None];
We get the probabilities for each class.
ci = ClassifierInformation[cl, "ProbabilitiesFunction"]
This generates a function that produces an Association:
Association[{0 -> (0.0307046 E^(8.58421 #1))/(
0.0307046 E^(0. + 8.58421 #1) + 0.675585 E^(0.836087 #2)),
1 -> 1./(1. + 0.0454489 E^(8.58421 #1 - 0.836087 #2))}] &
We can again use a little algebra to find the boundary.
boundaryExpression[a_Function] :=
y /. Quiet@
First@Simplify[Solve[Equal @@ a[x, y], y, Reals],
x \[Element] Reals];
boundaryExpression[cl_ClassifierFunction] :=
boundaryExpression[
ClassifierInformation[cl, "ProbabilitiesFunction"]]
We can now use this function to make a plot quite similar to the one above.
With[{be = boundaryExpression[cl]},
Show[ListPlot[
KeySort[GroupBy[
MapThread[List, {trainx, trainy}], (ToString[Last[#]] &) ->
First]], PlotMarkers -> {{"-", 18}, {"+", 18}}, Axes -> False,
Frame -> True],
Plot[be, {x, 0, 1}, PlotRange -> {{0, 1}, {0, 1}},
PlotStyle -> {Dashed, Black}]
]
]
Here's another way that does not require use of algebra. Instead we rely on RegionPlot and Ordering.
Show[ListPlot[
KeySort[GroupBy[
MapThread[List, {trainx, trainy}], (ToString[Last[#]] &) ->
First]], PlotMarkers -> {{"-", 18}, {"+", 18}}, Axes -> False,
Frame -> True],
RegionPlot[
Ordering[ci[x, y], -1][[1]] == 1, {x, 0 - 1, 2}, {y, -1, 2},
PlotRange -> {{0, 1}, {0, 1}}, BoundaryStyle -> {Dashed, Black},
PlotStyle -> {Opacity[0], White}]
]
By using RegionPlot we can readily extend the production of boundary diagrams to situations involving more than two classes.
cl3 = Classify[trainx -> trainy2,
Method -> {"LogisticRegression", "L1Regularization" -> 0,
"L2Regularization" -> 0}, TrainingProgressReporting -> None];
ci3 = ClassifierInformation[cl3, "ProbabilitiesFunction"];
c3plot = Show[
ListPlot[KeySort[
GroupBy[MapThread[List, {trainx, trainy2}], (ToString[Last[#]] &) ->
First]], PlotMarkers -> {{"-", 18}, {"+", 18}, {"2", 18}},
Axes -> False, Frame -> True],
RegionPlot[{Ordering[ci3[x, y], -1][[1]] == 1,
Ordering[ci3[x, y], -1][[1]] == 2, Ordering[ci3[x, y], -1][[1]] == 3}, {x,
0 - 1, 2}, {y, -1, 2}, PlotRange -> {{0, 1}, {0, 1}},
BoundaryStyle -> {{Dotted, Black}}, PlotStyle -> {Opacity[0.05]}]
]
![Boundaries with three classes][2]
I attach a notebook that recapitulates this post and adds an animation.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=classificationboundary.png&userId=20849
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=classificationboundary3.png&userId=20849Seth Chandler2017-12-14T15:27:16Z[✓] Print symbol names with Map?
http://community.wolfram.com/groups/-/m/t/1245233
Hi all,
to illustrate my question, I will use this toy example.
I would like to print the symbol names along with the length of the lists they're attached to. Like:
a = Range[1, 5];
b = Range[1, 10];
Print[SymbolName@Unevaluated@a, ": ", Length@a]
Print[SymbolName@Unevaluated@b, ": ", Length@b]
This works fine. But now, I would like to do that with Map:
Print[SymbolName@Unevaluated@#, ": ", Length@#] & /@ {a, b}
This doesn't work. It seems that the mapping evaluates the elements before to apply them to my pure function. Any help would be nice.Thanx,
FabriceFabrice Jossinet2017-12-14T16:32:12ZConsiderations concerning mathematical music theory
http://community.wolfram.com/groups/-/m/t/1245855
Good morning
years ago I wrote this preprint on Arxiv:
https://arxiv.org/abs/math/0402204
concerning Mathematical Music Theory.
I attach to this post all the related Mathematica code.
Thanking you very much for your kind attention I send you
my best regards
Dr. Gavriel SegreGavriel Segre2017-12-15T10:04:55ZCreating Star Wars Kylo Ren voice in one line of code
http://community.wolfram.com/groups/-/m/t/1219764
*MODERATOR NOTE: for true Star Wars fans this post has a related Wolfram Cloud App, which you can access by clicking on the image below. Read the full post below to understand how the app works. May the Force be with you.*
[![enter image description here][1]][9]
----------
Kylo Ren voice in [Star Wars The Force Awakens][2] is very cool. When I watched the movie in 2015, one of the first things that came up to my mind was how to do such voice in Mathematica. At the time Mathematica capabilities to manipulate sounds were very simplistic, and was not possible to do such thing.
I'm far far way to be a sound expert, but I tried do something like this:
file = Import["https://s3-sa-east-1.amazonaws.com/rmurta/murta-audio.wav"];
audioOrg = Audio[file];
audioKylo = AudioPitchShift[audioOrg, 0.9];
audioKylo = AudioFrequencyShift[audioKylo,-200]//AudioAmplify[#, 4]&
- Original Murta's record: [Murta original][3]
- And here is the result: [Murta as Kylo][4]
[![Kylo Voice][5]][6]
[youtube link for Kylo][7]
See [original post in Stack Exchange][8], where I ask for improvement in the sound hack.
After that, why not create a cloud app for that?!
This is amazing about Mathematica, with one line of code you can create a App, and everybody can play with It!
CloudDeploy[FormFunction[{"sound"->"Sound"},
AudioAmplify[AudioFrequencyShift[AudioPitchShift[#sound,0.9],-200],4]&],
"kylo-voice-by-murta",Permissions->"Public"]
Here is the link, so you can try it: [kyle-voice-by-murta][9].
Record your sound and speak like Kylo!
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at1.40.15PM2.png&userId=11733
[2]: https://en.wikipedia.org/wiki/Star_Wars:_The_Force_Awakens
[3]: https://s3-sa-east-1.amazonaws.com/rmurta/murta-audio.wav
[4]: https://s3-sa-east-1.amazonaws.com/rmurta/murta-kylo-audio.wav
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=kylo-voice2.png&userId=11733
[6]: https://www.youtube.com/watch?v=zy-wqB4cbT8&feature=youtu.be&t=49s
[7]: https://www.youtube.com/watch?v=zy-wqB4cbT8&feature=youtu.be&t=49s
[8]: https://mathematica.stackexchange.com/questions/159744
[9]: https://www.wolframcloud.com/objects/murta/kylo-voice-by-murtaRodrigo Murta2017-11-11T13:06:38ZUse remote kernel V11 + V5.2?
http://community.wolfram.com/groups/-/m/t/1245179
Can V5.2 Front End connect to a V11 Remote Kernel? Since I have just recently purchased V11 for my desktop, I thought that my laptop could run the old version that I still own, but I can't seem to get it to work, as the front end just hangs indefinitely when I try it. Since my new purchase was a home edition and didn't come with a second license, I'm trying to be frugal by using the old license also. Any thoughts?Christopher Arthur2017-12-14T22:24:39Z[✓] Use Select function in Dataset?
http://community.wolfram.com/groups/-/m/t/1244298
I have a list of earthquakes taken from Wolfram repository.
data = Reverse[Sort[ResourceData["Sample Data: US Earthquakes"]]]
I need to write two functions: the first one selects all earthquakes which have a magnitude of 6.0 to 8.0. Second selects all earthquakes which occurred from 2015 to 1995. Is there any way do that with "Select" function?Artem Anisimov2017-12-13T20:26:36ZGet solutions to the gauged GL vortices in (1+1) dimensions?
http://community.wolfram.com/groups/-/m/t/1240500
I am trying to numerically solve the following differential equations for the profiles of the Gauged GL Vortices:
eqn1 = y''[x] + y'[x]/x - ((k - z[x])^2* y[x])/x^2 + ((1 - y[x]^2)*y[x])/2 == 0;
eqn2 = z''[x] - z'[x]/x + (k - z[x])*y[x]^2 == 0;
with the boundary conditions:
inf = 1000;
bc = {y[0] == 0, y[inf] == 1, z[0] == 0, z[inf] == 1};
I have tried a finite difference method but this seems to give large errors even for k = 1 so I am wondering if there is a better numerical method to yield a more accurate solution?
Below is my current function which I employ to solve these coupled differential equations:
Clear[fdd, pdetoode, tooderule, sollst]
fdd[{}, grid_, value_, order_] := value;
fdd[a__] := NDSolve`FiniteDifferenceDerivative@a;
pdetoode[funcvalue_List, rest__] :=
pdetoode[(Alternatives @@ Head /@ funcvalue) @@ funcvalue[[1]],
rest];
pdetoode[{func__}[var__], rest__] :=
pdetoode[Alternatives[func][var], rest];
pdetoode[rest__, grid_?VectorQ, o_Integer] :=
pdetoode[rest, {grid}, o];
pdetoode[func_[var__], time_, {grid : {__} ..}, o_Integer] :=
With[{pos = Position[{var}, time][[1, 1]]},
With[{bound = #[[{1, -1}]] & /@ {grid},
pat = Repeated[_, {pos - 1}],
spacevar = Alternatives @@ Delete[{var}, pos]},
With[{coordtoindex =
Function[coord,
MapThread[
Piecewise[{{1, # === #2[[1]]}, {-1, # === #2[[-1]]}},
All] &, {coord, bound}]]},
tooderule@
Flatten@{((u : func) |
Derivative[dx1 : pat, dt_, dx2___][(u : func)])[x1 : pat,
t_, x2___] :> (Sow@coordtoindex@{x1, x2};
fdd[{dx1, dx2}, {grid},
Outer[Derivative[dt][u@##]@t &, grid],
"DifferenceOrder" -> o]),
inde : spacevar :>
With[{i = Position[spacevar, inde][[1, 1]]},
Outer[Slot@i &, grid]]}]]];
tooderule[rule_][pde_List] := tooderule[rule] /@ pde;
tooderule[rule_]@Equal[a_, b_] :=
Equal[tooderule[rule][a - b], 0] //.
eqn : HoldPattern@Equal[_, _] :> Thread@eqn;
tooderule[rule_][expr_] := #[[Sequence @@ #2[[1, 1]]]] & @@
Reap[expr /. rule]
Clear@pdetoae;
pdetoae[funcvalue_List, rest__] :=
pdetoae[(Alternatives @@ Head /@ funcvalue) @@ funcvalue[[1]], rest];
pdetoae[{func__}[var__], rest__] :=
pdetoae[Alternatives[func][var], rest];
pdetoae[func_[var__], rest__] :=
Module[{t},
Function[pde, #[
pde /. {Derivative[d__][u : func][inde__] :>
Derivative[d, 0][u][inde, t], (u : func)[inde__] :>
u[inde, t]}] /. (u : func)[i__][t] :> u[i]] &@
pdetoode[func[var, t], t, rest]]Benjamin Leather2017-12-06T11:13:47ZStep-by-step solutions of indefinite integral?
http://community.wolfram.com/groups/-/m/t/855400
Hi guys, do you know how could I solve an indefinite integral with step-by-step solution and specifying the variable of integration? For example:
WolframAlpha["cos(tw+f)cos(t*w)", IncludePods -> {"Indefinite Integral"}, PodStates -> {"Step-by-step solution", "Show all steps"}]
in this case Mathematica chooses as variable of integrazion w, but I would variable of integration is t. I tried to lunch:
WolframAlpha["[cos(tw+f)cos(t*w),{t}]", IncludePods -> {"Indefinite Integral"}, PodStates -> {"Step-by-step solution", "Show all steps"}]
but doesn't work.
Thank you for your help.Gennaro Arguzzi2016-05-12T16:05:30ZWhat Game of Thrones character do you resemble?
http://community.wolfram.com/groups/-/m/t/1242672
Hi all,
First time community poster here! I'll start off by saying, I am by no means an expert in machine learning. I dabble with the basic tutorials and training options offered by Wolfram, but when it comes to the guts of this stuff, I'm brand new. I say this as I think my project here is a good proof of concept on how easy it is to pick up machine learning with the Wolfram language. (Feel free to skip to the bottom of the post for a link to my notebook.)
**Initial testing**
To start out, I simply looked into the basic machine learning examples provided around our Mathematica 11 release, linked [here][1]. The [Create a Legendary Creature Recognizer][2] in particular is what I based my initial testing off of.
To start, I narrowed it down to two relatively different but very popular characters, Daenerys Targaryen and Jon Snow. Similar to the format in the creature recognizer, I simply imported images, associated them to the character name, and plugged this into my [Classify][3] function. To test it's capabilities, I used the "Top Probabilities" call to see with what confidence it was assigning characters.
Like I said, I'm new to machine learning, so this was a learning process for me. To my surprise, this solution was rather messy and just not at the level of accuracy I was looking for. It struggled with actors/actresses out of costume, was polluted by the background, and just didn't have enough images to be accurate.
This is what lead me to ultimately focus on 3 things when training my classifier function and eventually my neural networks. 1) Images of characters should include the actors or actresses both in and out of costume. 2) The [FindFaces][4] functions needed to be used to remove any background or outfit pollution. 3) The amount of images for each character needed to be as large as possible.
**Collecting images for my dataset**
Once I was able to mast extracting images using FindFaces, it was time to do some heavy internet image searching to get the relevant images. I decided to limit my identifier to just 7 characters: Dany, Jon, Tyrion, Cersei, Jaime, Arya, and Sansa (apologies to all of the Davos fans!) As mentioned before, I did specific searches for characters throughout the seasons as well as actors/actresses outside of costume (as well as additional searches for different hairstyles, facial hair, glasses, age, etc.)
To speed up this process, I first created a quick image tester to be sure that each of the images I pulled from my searches was being pulled correctly without having to test the entire dataset all at once. For example, I would test all of the season 1 images I found of Dany at one time. You can see what this looks like below.
![enter image description here][5]
testImgs = {}
i = 1;
testFaces = {};
While[i < Length[testImgs] + 1,
testFace = ImageTrim[testImgs[[i]], #] & /@ FindFaces[testImgs[[i]]];
AppendTo[testFaces, ImageResize[testFace[[1]], Tiny]];
i++;
]
testFaces
For proof of concept, the image includes a couple common errors that I found. In some cases, The image would not be able to find any faces per low-quality or just odd lighting/angles, in which would result in the error. In other cases, images would pick up background noise that resembled a face (not provided in this example). You can see in the last picture, another character's face was found first. These images would need to be removed from the set before being added to the full dataset. As I went along, it became easier to weed out images that would likely be unusable. You can see an example of what these image sets would look like below. Jaime's in particular was my smallest.
![enter image description here][6]
The final step in this process was to make the appropriate associations for the images and provide a list that could be used by the Classify function. You can see the code for this below. To summarize, I made separate lists of images for each character, then iterated through those list to associate them with the appropriate character name then add that associated object to my master list.
faceRec = {};
i = 1;
While[i < Length[dt] + 1,
dtface = ImageTrim[dt[[i]], #] & /@ FindFaces[dt[[i]]];
AppendTo[faceRec, ImageResize[dtface[[1]], {100, 100}] -> "Dany"];
i++;
]
i = 1;
While[i < Length[js] + 1,
jsface = ImageTrim[js[[i]], #] & /@ FindFaces[js[[i]]];
AppendTo[faceRec, ImageResize[jsface[[1]], {100, 100}] -> "Jon"];
i++;
]
i = 1;
While[i < Length[tl] + 1,
tlface = ImageTrim[tl[[i]], #] & /@ FindFaces[tl[[i]]];
AppendTo[faceRec, ImageResize[tlface[[1]], {100, 100}] -> "Tyrion"];
i++;
]
i = 1;
While[i < Length[cl] + 1,
clface = ImageTrim[cl[[i]], #] & /@ FindFaces[cl[[i]]];
AppendTo[faceRec, ImageResize[clface[[1]], {100, 100}] -> "Cersei"];
i++;
]
i = 1;
While[i < Length[jl] + 1,
jlface = ImageTrim[jl[[i]], #] & /@ FindFaces[jl[[i]]];
AppendTo[faceRec, ImageResize[jlface[[1]], {100, 100}] -> "Jaime"];
i++;
]
i = 1;
While[i < Length[as] + 1,
asface = ImageTrim[as[[i]], #] & /@ FindFaces[as[[i]]];
AppendTo[faceRec, ImageResize[asface[[1]], {100, 100}] -> "Arya"];
i++;
]
i = 1;
While[i < Length[ss] + 1,
ssface = ImageTrim[ss[[i]], #] & /@ FindFaces[ss[[i]]];
AppendTo[faceRec, ImageResize[ssface[[1]], {100, 100}] -> "Sansa"];
i++;
]
faceRec = RandomSample[faceRec, Length[faceRec]];
Per a note from one of our developers, I also chose to randomize the list of associations, as our neural network framework down assume a random order when processing. This didn't provide any noticeable difference in my dataset, but I thought it was an important thing to at least note.
**Using the Classify function**
With my images associated, I was ready to jump into creating my ClassifierFunction. With a single line of code, I was able to do so, as seen below.
gotFaces = Classify[faceRec]
To test my model, I pulled in some new images and used the same logic as before to create a testing set. I did try to find images in costume as well as in real life, with different hairstyles, and at different ages to provide some more variety in my testing.
![enter image description here][7]
test = {}
i = 1;
testFaces = {};
While[i < Length[test] + 1,
testFace = ImageTrim[test[[i]], #] & /@ FindFaces[test[[i]]];
AppendTo[testFaces, ImageResize[testFace[[1]], {100, 100}]];
i++;
]
testFaces
I will note, that doing this same process to this point with just Jon and Dany worked REALLY well. To my surprise, though, it just wasn't quite as promising with a larger cast of characters. Some characters were correct with relatively high confidence, some were right but with a split between a few characters, and some were wrong but at least had the correct character in close proximity to the top character.
Manipulate[gotFaces[character, "TopProbabilities"], {character, testFaces}]
![enter image description here][8]
![enter image description here][9]
![enter image description here][10]
This had me troubleshooting like crazy. I will say that simply duplicating the associations already in the list several times actually improved the accuracy quite a bit, which was expected. With this in mind, I decided to try my hand at our neural network functionality.
**Using the NetChain and NetTrain functions**
I'll say it once, and I'll say it again. I am by no means an expert in neural networks. It's a big topic in tech now, so I've developed a basic conversational understanding of the concept. However, this was my first time actually creating my own neural network in any language.
The process was relatively simple, much to my surprise, thanks to Wolfram's vast amount of documentation. Per some research, I learned about "convolutional" neural nets and found a similar image example of this in our documentation pages for [NetTrain][11]. Using this example, I made some minor adjustments to the NetChain to fit this to my own data and was well on my way to training my first neural net! You can see what this ended up looking like below. The variable "classes" simply being all of the potential characters.
lenet = NetChain[
{ConvolutionLayer[20, 5], Ramp, PoolingLayer[2, 2],
ConvolutionLayer[50, 5], Ramp, PoolingLayer[2, 2], FlattenLayer[],
500, Ramp, 7, SoftmaxLayer[]},
"Output" -> NetDecoder[{"Class", classes}],
"Input" -> NetEncoder[{"Image", {100, 100}}]
]
From here, the NetTrain function is super simple. You can see an image of what this looks like in motion below with real-time training progress as the program runs. For larger sets of data, there is also the option to add a time goal. For mine, I simply allowed it to run for the full 10-15 minutes. It's certainly interesting to be able to actually see the loss function change as the data set runs.
trained = NetTrain[lenet, faceRec]
![enter image description here][12]
This method did still have its errors but the accuracy as well as the confidence in the selections did seem to be significantly higher. I saw much more examples of split "TopProbabilities" for the wrongly classified images, as with the Dany and Arya pictures below, but also a much larger level of correctly classified images with 90%+ as their "TopProbabilities" return, as with the Jon and Sansa pictures below.
Manipulate[trained[character, "TopProbabilities"], {character, testFaces}]
![enter image description here][13]
![enter image description here][14]
![enter image description here][15]
![enter image description here][16]
As with the Classify function, adding more images (even duplicates) to the dataset did provide even more accurate results and confidence to the neural net model. Ideally, if using this for an actual application, I would have a more elegant way of importing the images in for the NetTrain. A suggestion from a meeting I sat in recently was to explore [NetEncoder][17]. I also got the vibe that there are some other options in the pipeline to support this, specifically with large numerical datasets.
**Real-time character matching**
Moving on to the fun part that you've all been waiting for! I started out by using the same logic as with my character image import to pull in images from LinkedIn of my coworkers to see how the ClassifierFunction and NetChain handled these outside inputs.
![enter image description here][18]
wolfram = {}
i = 1;
wolframFaces = {};
While[i < Length[wolfram] + 1,
wolframFace = ImageTrim[wolfram[[i]], #] & /@ FindFaces[wolfram[[i]]];
AppendTo[wolframFaces, ImageResize[wolframFace[[1]], {100, 100}]];
i++;
]
wolframFaces
I understand that this is not exactly what deep learning is intended for, but it's a fun little application to try to trick the trained sets to force us into a character. The models definitely vary on what character they give to each coworker, so it is noticeable that their methods are likely quite different. However, it did give a highly odd confidence for some of my coworkers in both cases.
Manipulate[
gotFaces[employee, "TopProbabilities"], {employee, wolframFaces}]
![enter image description here][19]
And finally, the quiz you've all been waiting for. THE LIVE IDENTIFIER! You can see a quick image of what this looks like below. It uses the camera on your computer to allow you to grab a live image of yourself and run this through the ClassifierFunction and NetChain.
Panel[
Column[{
Row[{ImageCapture[ImagingDevice -> $ImagingDevice]}],
Row[{
Button[TextCell["Grab Image", FontSize -> 24],
img = CurrentImage[ImageSize -> 900], ImageSize -> {337, 50},
Alignment -> Center]
}],
Row[{TextCell["Captured Faces", Bold, FontSize -> 24]},
Alignment -> {Top, Center}],
Row[{Dynamic[currentFace = ImageTrim[img, #] & /@ FindFaces[img]]}],
Row[{TextCell["Classify function ID", Bold, FontSize -> 24]}],
Row[{Dynamic[
Style[gotFaces[currentFace, "TopProbabilities"],
FontSize -> 16]]}],
Row[{TextCell["Neural net ID", Bold, FontSize -> 24]}],
Row[{Dynamic[
Style[trained[currentFace, "TopProbabilities"],
FontSize -> 16]]}]
}
], ImageSize -> 355]
![enter image description here][20]
It's interesting to use this "live" model to start exploring how the input images are affecting the final trained sets. I noticed that although I tended to lean towards a small group of characters (especially in the Neural net ID), some particular factors could vary the outputs. Image quality (per camera or amount of cropping from not being close enough), head tilt, hair in face, facial expressions, etc. did provide some level of variation in my quick analysis.
**Closing thoughts**
Although not a perfect model, it's been really reassuring to know the level of accuracy obtained on such a small dataset and with very little knowledge of the appropriate neural networks to be used with this type of analysis. Being able to jump right in per the support of the Wolfram documentation as well as the ease of built-in functions made it SUPER easy to build such a model from scratch.
If I were looking to develop further, I would like to explore more about neural networks geared towards facial recognition as well as better way to collect as well as import a vast dataset of even more characters. It would be my hope that this would 1) better identify certain defining features and 2) eliminate the variations that we see more obviously in the live camera model.
It's not perfect, but what a fun proof of concept and a great learning experience! You can download all of the files at the following links: [full notebook][21], [trained NN][22], and [webcam app][23]. Specifically, the GOTFacesApplication is a more simplistic model that imports the .wlnet model vs. having you have to sit and wait for the full project notebook to evaluate. Since some of the Import/Export on the [WLNet][24] functionality is still "experimental", I hit some snags on creating a CDF to be used with our free CDF player (my apologies to those who haven't made the jump to Mathematica yet!)
Hope you all enjoy!
[1]: https://www.wolfram.com/language/11/improved-machine-learning/?lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[2]: https://www.wolfram.com/language/11/improved-machine-learning/create-a-legendary-creature-recognizer.html?product=language&lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[3]: http://reference.wolfram.com/language/ref/Classify.html?lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[4]: http://reference.wolfram.com/language/ref/FindFaces.html?lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAA6zAAAAJDEwNTRhMDhjLTU4MTQtNGUxYy05NGZmLWE2MGQwMTNhOWYwZg.jpg&userId=1161398
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAA5kAAAAJGQwNjFmMzRiLTIyNzQtNGE0Ni1iOGVhLWJmMmVkZjdjMTFiNg.jpg&userId=1161398
[7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAAtPAAAAJGQ0Y2M3NGFjLTM3ZDEtNDU2Yy04NDRiLWNlMzQ3ZDUwZWE5OA.jpg&userId=1161398
[8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAA18AAAAJDYxZWZmYTEzLTViYWEtNDVmZC05NThiLTZiYzQ2MGY0NTQ3OA.jpg&userId=1161398
[9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAA8XAAAAJDkzMzcyNTQyLTU2YmEtNDkxYi04Zjk1LWY3NjQ3MWJlY2VhMA.jpg&userId=1161398
[10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAAxKAAAAJDExODhmNzczLTQyNjMtNGY4MC04ZTA2LTgzMTY2MTczYzMxMg.jpg&userId=1161398
[11]: http://reference.wolfram.com/language/ref/NetTrain?lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAAuBAAAAJDhiMmNhMjU2LTJhOWYtNGE3OC04NWFlLTczNWViMDYzNzU1Yg.jpg&userId=1161398
[13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAAvlAAAAJDI3NGYyMDAxLWQyNWQtNGM5NC1iZjNjLTU5NDdhYzdmZmY0YQ.jpg&userId=1161398
[14]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAA7eAAAAJGRkMTBkYWY1LTNiMGUtNDA5NS05YTk2LTg5MGIwYzVlNzE3Zg.jpg&userId=1161398
[15]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAA8KAAAAJGViNzc1MDU4LTUzZGUtNGY1ZC1hMWY3LTlkYzExNzVjMGRiZA.jpg&userId=1161398
[16]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAApWAAAAJDdhMGQ4YjI3LTg5OGEtNGE3Yi1hODY2LTIzMzE2Njc5NjIyOA.jpg&userId=1161398
[17]: http://reference.wolfram.com/language/ref/NetEncoder.html?lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[18]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAA1QAAAAJDFiNDRlNWYyLWI5ZDAtNDA0Zi1hYTdmLTBlMGQ4MzBmNjFmNw.jpg&userId=1161398
[19]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAAnJAAAAJDdmMmExMzI5LWQwM2MtNDE3My1iNDBlLTJkODc2YmIxMTVkMw.jpg&userId=1161398
[20]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAAtuAAAAJDMxNzIyOTljLWFkYTUtNDBkMC1iNWIyLTZjODNhYmZiMzE0Yg.jpg&userId=1161398
[21]: https://amoeba.wolfram.com/index.php/s/blYdcZCDLJvRbPq
[22]: https://amoeba.wolfram.com/index.php/s/M9ZuFlCQ7xjj2Cp
[23]: https://amoeba.wolfram.com/index.php/s/IwEnxaioz28IwrI
[24]: http://reference.wolfram.com/language/ref/format/WLNet.html?lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==Sam Tone2017-12-11T23:40:19ZSolve differential equations with steps using the W|A ios App?
http://community.wolfram.com/groups/-/m/t/1244443
Does anyone know if the ios app can solve differential equations with steps?Jordan S2017-12-12T22:09:42Z[✓] Get eigenvalues of a real symmetric matrix?
http://community.wolfram.com/groups/-/m/t/1148141
Hello,
I am using Wolfram Alpha widgets for calculating Eigen values of a 3X3 real symmetric matrix. It is known the a real symmetric matrix has real Eigen values.
However, the calculator is giving roots with iota (complex looking roots). So I have two questions,
1) Are the Eigen values computed by the widget actually complex?
2) If eigen values are not complex, then why aren't they simplified and given? How do I simplify them?
The matrix which I used is :
A = [ [ 1 2 3],
[2 1 2],
[3 2 3] ]
Here is the link also,
http://www.wolframalpha.com/widgets/view.jsp?id=9aa01caf50c9307e9dabe159c9068c41
Thanks in advance. Hoping to hear from you soon.
Sandhya
P.S. : For the above matrix A, real Eigen values are 6.569, -1.342, -0.227.Sandhya Tripathi2017-07-17T06:41:33ZPlot for a solution of the following equation?
http://community.wolfram.com/groups/-/m/t/1244489
I have run a command of Plot for a solution of an equation. However, the graph is always empty. I don't know what's wrong with my code. Could anyone help me to figure it out?
My code is following:
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=code.jpg&userId=1232269Tim Zhang2017-12-12T23:57:12ZPalette user interface
http://community.wolfram.com/groups/-/m/t/1238569
Hi all,
I am using Wolfram Mathematica about 10 years, but the user interface did not improve substantially. I really upset that such innovative company as Wolfram Research did not provide any useful alternative of palettes and docked cells for packages developers.
From my own point of view the palettes have several shortcomings.
1. they overlay each other and notebooks. Users have to waste more time for allocate the palettes than use them. Typically users open several notebooks and the next one notebook opens on its own place of screen without any correlation with the palettes. Finally users decide to close the palettes.
2. the functional of the palettes is scarce. Some package developers prefer to create a small notebook with buttons rather than the palette.
3. the palettes look archaic in comparison with other programs.
----------
For example, a ribbon interface has proved effective. Take a look at MS Word, Matlab, Foxit Reader and so on. Or maybe one can use a tabbed document interface for notebooks.Mikhail Cherkasskii2017-12-04T06:31:52Z[✓] Get plot with just axes crossing at the origin?
http://community.wolfram.com/groups/-/m/t/1242000
Hi, when I plot (3D) a 2 variable scalar function in wolfram Mathemática I always get the function in a box formed by the axis. How could I get rid of that box and just see the surface I´m plotting and the three ortogonal axis crossing at the origin??Victor Gutierrez2017-12-09T11:01:10ZI’m okay with making name tags with Mathematica
http://community.wolfram.com/groups/-/m/t/1244333
*This post was originally published at [Ultimaker][1].*
----------
Pioneer Chris Hanusa led a Mathematica and 3D printing workshop where he shared resources to help attendees get up and running with the program and 3D printing. At the end of the information-rich workshop, attendees learned how to to use Mathematica to create several 3D printable objects, including name tags.
In October, at my invitation, Assistant Professor Chris Hanusa of the Math Department at Queens College led an Introduction to 3D printing with Mathematica workshop for educators at [NYU’s ITP][2] in New York City. Chris is a mathematician and a designer who creates beautiful objects inspired by math (you can see his work on his website [hanusadesign][3]). Chris creates his objects and shares the math behind them on his site. He has also written several tutorials on his [blog mathzorro.com][4] about how to use Mathematica to create 3D objects. There is a great deal to learn about Mathematica before one can start designing printable 3D objects, and during the workshop Chris worked to provide the attendees with enough information to be just a little bit dangerous. Without a question, Mathematica is the kind of application that one needs to see in action, and then spend quite a bit of time with processing the information and doing further exploration on one’s own.
Chris’s teaching style encourages independence. He shows his college students how to rely on Mathematica’s extensive documentation, and he provides well-scaffolded tutorials to follow so that his students develop their understanding and confidence.
[Mathematica][5] is not a CAD package, nor was it created with 3D printing in mind. However, one can use Mathematica’s programing language to create printable 3D objects, basically watertight, mesh files and export them as STLs or OBJs. Like other programming languages (Processing, Openscad, OpenGL) that can create 3D objects with code, you don’t have the ability to drag and drop shapes. Basically, you create statements that generate nodes or vertices in 3D space. By specifying coordinates, you can then apply rotate, scale and translate transformations. You can use parametric curves, vector functions, and trigonometry to create your geometric objects. Remember when you asked in Trig class "When will ever use this?" Well, you’ll use your trig in Mathematica to create 3D printable objects. Math class would have been very different for me if I had access to both Mathematica and 3D printing back when I was in high school.
What I like about Mathematica (and Processing and OpenSCAD) is the algorithmic approach to generating objects. While Processing uses a sketch metaphor and OpenSCAD employs an editing window, Mathematica uses notebooks. For each of these options, programmers start with a general idea of a task for their computers to perform. Programmers then flesh out their general ideas into complete, unambiguous, step-by-step procedures to carry out their tasks. Such procedures are called algorithms. An algorithm is not the same thing as a program. A program is written in some particular programming language, like C, Java, Python, or the Wolfram Language. An algorithm is more like the idea behind the program. An algorithm can be expressed in any language, including English.
When you know what you want your program to do, many programmers find it helpful to write a description of the task or tasks. That description can then be used as an outline for their algorithm. As a programmer refines and elaborates on their description, gradually adding more details, they eventually end up with a complete algorithm that can be translated directly into a programming language. This method is called stepwise refinement, and it is a type of top-down design. As you proceed through the stages of stepwise refinement, you write out descriptions of your algorithm in pseudo-code, the informal instructions that imitate the structure of your program without complete details or the perfect syntax of actual code. Pseudo-code is where you figure out what kinds of data your program needs and what kind of data it returns. This is also the step where you think about the best way to solve the problems that you're going to run into during the project, and to you get to figure out solutions to try before even starting to write code.
Think of programming as a process of logical problem-solving. Your two big challenges are a) learning the syntax, and b) applying your logical problem-solving skills to an unfamiliar domain. When I taught programming at [Saint Ann’s School][6] in Brooklyn, NY, I told my students who were learning a new language to break things down into four areas:
- Code-reading—be able to look at code and figure out what it’s doing. Code-reading means two things:
- Being able to understand what a particular line of code is doing -
understanding the syntax of the program.
- It also means understanding something called the control flow of the program: when the program executes a line of code, what will it execute next?
- Pseudo-code—This is where you do a lot of thinking and not a lot of
writing code. Because most projects start with a vague idea, or an
English description, this step helps turn your project into something
that is approachable as a program. It forces you to define and
explain what you're trying to do very precisely.
- Code-writing—It can be intimidating to try and figure out how to
express what you're trying to do with an unfamiliar syntax of a
programming language. However, if you've done a good job with the
pseudo-code, writing your code should be in some ways the simplest
step. You’re performing a translation from the precise and clear
concepts you've figured out to the syntax of the programming language
in question. As you write the code, you'll figure out some issues
that your original design or pseudo-code didn't address. You'll
improvise, double back, and sometimes change your entire design. But
the more you separate the simple writing of code from the hard work
of figuring out what you want the code to do, the happier you will be
in the long run.
- Debugging—This is the process of testing and fixing the problems in a
program that you've already written. Unfortunately, this is the step
that will generally take most of your time. While occasionally you
will be able to write a program that's bug-free, generally your
program will either not work immediately or it will do something
completely unexpected. Learning techniques for figuring out what's
wrong (and even more important, solving the problem) is important.
The more code you write and the longer your programs become, the
harder problems become to track down and deal with.
Start small, modify, test and build incrementally. When you work in Mathematica, instead of modifying code that works, make a copy and modify the copy. This way you’ll have a record of what you started with that you can always return to at a later date.
Mathematica is also capable of nested commands. But ease into this. Until you know how each command works (what information a command takes and what it returns) you may want to consider separating the commands out. As you become more experienced, nest away with confidence.
During the workshop, Chris pointed out a few things that were helpful to keep in mind:
- Mathematica is case sensitive.
- All built-in Mathematica functions are spelled, capitalized, and
follow CamelCase rules.
- It is important to distinguish between parentheses (), brackets [],
and braces {}: Parentheses (): Used to group mathematical
expressions, such as (3+4)/(5+7). Brackets []: Used when calling
functions, such as N[Pi]. Braces {}: Used when making lists, such as
{i,1,20}.
- To calculate an expression, use Shift-Return.
- To find the options of a given function, highlight it in the notebook
and then press Command+Shift+F.
- A semicolon can be used to suppress output.
- Mathematica has four types of equals: =, ==, :=, and ===.
- Assignment: To define a variable to store it in memory, use =. For example, to define z to be 3, write z=3.
- Test for equality: Use == to check for equality. For example, 1-1==0 will evaluate to True and 1==0 will evaluate to False.
- Set Delay: Use := when you want to evaluate the function when it is called rather than when it is assigned . (This is advanced.)
- SameQ: Use === to test whether two expressions are identically the same.
- Adding comments to your notebook will help you remember what your intentions were when you look back on your notebook months later. Comments are also invaluable for other people who are navigating through your notebook. To write a sentence, create a new text cell by clicking below a cell. When the cursor turns horizontal type Option-7, or right click and navigate to Insert New Cell > Text.
- Use the documentation. If you are having trouble with a certain
function, use the ? command to ask for help. For example enter ?
Table and the output will be a yellow box with a quick synopsis of
the command. For more detailed information, click the blue >> at the
bottom right of this yellow box. This will open the Documentation
Center which gives examples of using the command in action, available
options for this command, and anything else you might want to know
about the command.
The following three statements represent a sphere, a cuboid and a cone:
Sphere[{0, 0, 0}, .28]
Cuboid[{-.05, -.05, .26}, {.05, .05, .35}]
Cone[{{0, 0, 0}, {0, 0, -1}}, .3]
You can also combine them using a list
Graphics3D[{
Sphere[{0, 0, 0}, .28],
Cuboid[{-.05, -.05, .26}, {.05, .05, .35}],
Cone[{{0, 0, 0}, {0, 0, -1}}, .3]
}]
They are combined, but if you press Shift Return, I suspect you may not get what you expect.
In order to see all the objects combined you have to pass these objects from Graphics3D[] to Show[]:
sphere = Graphics3D[Sphere[{0, 0, 0}, .28]]
cuboid = Graphics3D[Cuboid[{-.05, -.05, .26}, {.05, .05, .35}]]
cone = Graphics3D[Cone[{{0, 0, 0}, {0, 0, -1}}, .3]]
Show[sphere, cuboid, cone]
Like other programming languages, there's often more than one way to do do the same thing:
shapes = {
Sphere[{0, 0, 0}, .28],
Cuboid[{-.05, -.05, .26}, {.05, .05, .35}],
Cone[{{0, 0, 0}, {0, 0, -1}}, .3]}
Map[Graphics3D, shapes]
Show[Map[Graphics3D, shapes]]
Graphics3D[Table[Sphere[{i, 0, 0}, .2], {i, 0, 10}]]
To get the workshop attendees started, Chris created a [Mathematica Basics Crash Course][7] and a [3D Graphics in Mathematica][8] notebook.
If you're new to Mathematica, open Chris’s notebooks and execute each command by placing your cursor at the end of the line and pressing Shift+RETURN. Not everything will make sense right away, and that’s okay. Mathematica is packed with information and functionality. At the beginning just try to appreciate what it is doing, and then marvel at what might be possible when you have more experience.
Mathematica has a large number (195) of built-in polyhedra that you can create, export and print. They are accessible using the command PolyhedronData[]. How do I know how many polyhedra Mathematica can represent? Execute the following statement:
Length[PolyhedronData[All]]
To find out the properties associated with PolyheronData[] execute the following command:
PolyhedronData["Properties"]
And here is a handy statement to explore all the polyhedra:
Manipulate[
Column[{PolyhedronData[g], PolyhedronData[g, p]}], {g,
PolyhedronData[All]}, {p,
Complement @@ PolyhedronData /@ {"Properties", "Classes"}}]
Here how to create a 3D object that you can see and then export:
myShape = Graphics3D[PolyhedronData["Icosahedron", "Faces"]]
![enter image description here][9]
Save your notebook. Then to export the object as an STL file :
Export[NotebookDirectory[] <> "myFile.stl", myShape]
And then to see the STL:
Import[NotebookDirectory[] <> "myFile.stl"]
#Back to name tags#
Name tags or nameplates often seem to me to be the Hello World of 3D printing. They are generally pretty simple to create with a CAD package and they provide an easy introduction to 3D space. There is nothing inherently wrong with creating name tags or nameplates, but I think 3D printing is capable of so much more, and I try to advocate for finding the real potential for 3D printing in education. Yet here I am, encouraging you to use Mathematica to create a name tag. Why? Because I think it is helpful to start off with a familiar object in an unfamiliar context. Remember, Mathematica won’t let you click and drag. You are going to have to build a name tag from the ground up, and in the process, you’re going to become familiar with some of Mathematica’s mesh commands.
At it’s simplest, to make a name tag, you’re going to need a base and then a top. Remember that an STL file is a watertight mesh. That means that where the base and the top meet you will need to eliminate the top surface on the base and the bottom surface of the top. Let’s start with some text:
Text[Style["Ultimaker", Bold, FontFamily -> "Futura", FontSize -> 50]]
![enter image description here][10]
You now need to convert this text to a 2D mesh. To do that you use the command DiscretizeGraphics[]:
meshText2d = DiscretizeGraphics[
Text[Style["Ultimaker", Bold, FontFamily -> "Futura",
FontSize -> 50]], _Text]
![enter image description here][11]
To make the 2D mesh 3D use RegionProduct[] with the mesh and a vertical line:
RegionProduct[meshText2d, Line[{{0.}, {5.}}]]
![enter image description here][12]
Next you’ll create a 2D mesh of a polygon to act as the base:
base = DiscretizeGraphics[Graphics[{RegularPolygon[8]}]]
![enter image description here][13]
To see the two meshes together:
Show[{RegionResize[base, 1.3], RegionResize[meshText2d, 1]}]
![enter image description here][14]
Next you need to remove the surfaces where the two meshes intersect (RegionDifference[]) and make the base big enough to support the text (RegionResize[]):
polygon = RegionResize[base, 1.3];
text = RegionResize[meshText2d, 1];
intersection = RegionDifference[polygon, text]
![enter image description here][15]
Now you need to create boundaries from the two regions so that you can create walls:
bdrypolygon = RegionBoundary[polygon]
bdrytext = RegionBoundary[text]
![enter image description here][16]
![enter image description here][17]
Now you need to build the actual mesh. You’ll need to create 3 levels: the floor, the top of the base and the top of the text (You must use a floating point number):
level0 = 0.;
level1 = 0.1;
level2 = 0.15;
Now it’s time to put all the parts together:
Show[{
RegionProduct[polygon, Point[{{level0}}]],
RegionProduct[bdrypolygon, Line[{{level0}, {level1}}]],
RegionProduct[intersection, Point[{{level1}}]],
RegionProduct[bdrytext, Line[{{level1}, {level2}}]],
RegionProduct[text, Point[{{level2}}]]
}]
![enter image description here][18]
Export and Import. You can use the % as shorthand for the last thing you created:
Export[NotebookDirectory[] <> "nametag.stl", %]
Import[NotebookDirectory[] <> "nametag.stl"]
![enter image description here][19]
If the export doesn’t work, it could be that your notebook hasn’t been saved yet. Save the notebook, then export and import.
But what if you want to use a logo instead of text? No problem. Start with an image, convert it to a 2D mesh, resize it, convert to 3D, create a base, eliminate the surface where the meshes intersect, create boundaries, establish level values, and then put them all together.
Find a black and white image online, copy it, and then create a variable to hold it. Use the semicolon to suppress the output:
![enter image description here][20]
To convert a bitmap to a mesh first negate the color then use ImageMesh[] instead of DiscretizeGraphics[]:
catMesh=ImageMesh[ColorNegate[cat]]
![enter image description here][21]
Next, you need to scale the image:
scaledCat = RegionResize[catMesh, {{-.8, .8}, {-.6, .6}}]
![enter image description here][22]
Lets use a disk for the base. You’ll need to convert it to a mesh and make it slightly larger than 1 unit. (Remember you just scaled your image to be slightly smaller than the unit length:
base = DiscretizeGraphics[Graphics[{Disk[{0, 0}, 1.1]}]]
![enter image description here][23]
Let’s make a hole in the base:
hole = DiscretizeGraphics[Graphics[{Disk[{0, .9}, .1]}]]
To make sure everything fits:
Show[{base, hole, scaledCat}, PlotRange -> All]
![enter image description here][24]
Let’s first make the hole in the base:
base = RegionDifference[base, hole]
![enter image description here][25]
Now find the intersection:
intersection=RegionDifference[base, scaledCat]
![enter image description here][26]
Now you need to get the boundary of the 2D mesh:
bdryCat = RegionBoundary[scaledCat]
bdryBase = RegionBoundary[base]
![enter image description here][27]
![enter image description here][28]
Create the levels:
level0 = 0.;
level1 = 0.15;
level2 = 0.25;
And now to put it all together:
Show[{
RegionProduct[base, Point[{{level0}}]],
RegionProduct[bdryBase, Line[{{level0}, {level1}}]],
RegionProduct[intersection, Point[{{level1}}]],
RegionProduct[bdryCat, Line[{{level1}, {level2}}]],
RegionProduct[scaledCat, Point[{{level2}}]]
}]
![enter image description here][29]
Export and print!
There you have it: a name tag in Mathematica. Not only did you get to learn a little about Mathematica, but you also got to see how meshes from two shapes are constructed. Where does Mathematica and 3D printing fit in the curriculum? Math class is an obvious answer, but it’s also well suited for a programming class, and with access to computers, patience and time, why not bring Mathematica and 3D printing to the art studio?
Here’s a challenge: Try [Mathematica][30] for 15 days and see what you can do with it. Upload your 3D models to [Youmagine][31] and tag them #MathematicaAnd3DPrinting.
[1]: https://ultimaker.com/en/blog/51553-im-okay-with-making-name-tags-with-mathematica
[2]: https://tisch.nyu.edu/itp
[3]: http://hanusadesign.com/
[4]: http://blog.mathzorro.com/
[5]: https://www.wolfram.com/mathematica/
[6]: http://saintannsny.org/
[7]: https://qcpages.qc.cuny.edu/~chanusa/mathematica/Basics.nb
[8]: https://qcpages.qc.cuny.edu/~chanusa/mathematica/GraphicsObjects.nb
[9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=2084polyhedra.png&userId=20103
[10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=text.png&userId=20103
[11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=01_mathematica_text.png&userId=20103
[12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=02_mathematica_3D.png&userId=20103
[13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=312203_polygon.png&userId=20103
[14]: http://community.wolfram.com//c/portal/getImageAttachment?filename=713504_base_text_together.png&userId=20103
[15]: http://community.wolfram.com//c/portal/getImageAttachment?filename=672905_intersection.png&userId=20103
[16]: http://community.wolfram.com//c/portal/getImageAttachment?filename=326906_boundary_base.png&userId=20103
[17]: http://community.wolfram.com//c/portal/getImageAttachment?filename=943207_boundary_text.png&userId=20103
[18]: http://community.wolfram.com//c/portal/getImageAttachment?filename=08_mesh.png&userId=20103
[19]: http://community.wolfram.com//c/portal/getImageAttachment?filename=09_stl.png&userId=20103
[20]: http://community.wolfram.com//c/portal/getImageAttachment?filename=10_cat.png&userId=20103
[21]: http://community.wolfram.com//c/portal/getImageAttachment?filename=11_remove_color.png&userId=20103
[22]: http://community.wolfram.com//c/portal/getImageAttachment?filename=12_resize.png&userId=20103
[23]: http://community.wolfram.com//c/portal/getImageAttachment?filename=488713_base.png&userId=20103
[24]: http://community.wolfram.com//c/portal/getImageAttachment?filename=14_show.png&userId=20103
[25]: http://community.wolfram.com//c/portal/getImageAttachment?filename=719215_hole.png&userId=20103
[26]: http://community.wolfram.com//c/portal/getImageAttachment?filename=16_intersection.png&userId=20103
[27]: http://community.wolfram.com//c/portal/getImageAttachment?filename=735417_boundary_cat.png&userId=20103
[28]: http://community.wolfram.com//c/portal/getImageAttachment?filename=668918_boundary_base.png&userId=20103
[29]: http://community.wolfram.com//c/portal/getImageAttachment?filename=19_mesh.png&userId=20103
[30]: https://www.wolfram.com/mathematica/trial/
[31]: http://youmagine.com/Lizabeth Arum2017-12-12T18:51:20ZAvoid error in ImageAugmentationLayer usage?
http://community.wolfram.com/groups/-/m/t/1243036
This code fails with "NetTrain::interr: An internal error occurred. Please contact Wolfram Research. " Any ideas?
lnet = NetChain[
{
ImageAugmentationLayer[{115, 115},
"ReflectionProbabilities" -> {0.5, 0.5}],
LinearLayer[1788],
LogisticSigmoid,
LinearLayer[1788],
2,
SoftmaxLayer[]},
"Output" -> NetDecoder[{"Class", {1, 2}}],
"Input" -> NetEncoder[{"Image", {125, 125}}]
] ;
tSet = Table[
RandomChoice[{RegionImage[Annulus[], RasterSize -> 125] -> "A",
RegionImage[Circle[], RasterSize -> 125] -> "C"}], 10]
NetTrain[lnet, tSet]Jeff Burns2017-12-11T21:10:40ZFind intersection points of lines using ListPlot?
http://community.wolfram.com/groups/-/m/t/1242003
Hello, I am trying to find the intersection points of the two horizontal solid lined with the dashed line. I would like to label each point as for example point a and the second point as b. I would also like to display the value of the intersecting point. Note that I am aiming to find the x value of the intersecting point since I know y. I find it easier with function and using Plot function. I tried with this one but it didn't work.
Thank you
list1 = {0, 1};
list2 = {0, 5};
ListLinePlot[Transpose[{list1, list2}], PlotStyle -> {Thick, Dashed},
PlotRange -> {{0, 5}, {0, 5}},
GridLines -> {None, {{2, {Black, Thick}}, {4, {Green, Thick}}}}]Joeseph A2017-12-08T18:27:16ZProblem: Light transport through biological tissue
http://community.wolfram.com/groups/-/m/t/1241248
I'm new to Mathematica and while it seems like there should be a way to do this (it is effectively simultaneous equations) I don't know how to input it to Mathematica. I've tried using solve and setting it in a table first but it seems I'm not realizing something or missing something in the documentation about how to play with a few.
The problem represents light passing through tissue. There are two variables in the equation that I need to know, a and b. (if there is a method to input equations/code here can someone point it out to me?)
![enter image description here][1]
I(lam), I0(lam) are measured values. I will know these, they are the intensity of the light coming out and going into the volume at wavelength lambda. M(lam) is the absorption of tissue at the wavelength lamda, this I will also know at all lambdas.
d thickness of the tissue, this is a set value.
a and b are what I would like to know. That term represents the light scattering function for the tissue.
What I would like mathematica to do is tell me how many lambda's, or colors of light, do I have to measure at to find what a and b are, and the equation that gives me a and b.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=KsqisKw.png&userId=20103Alan Riordan2017-12-07T12:03:56ZGetting data from an analog-to-digital converter
http://community.wolfram.com/groups/-/m/t/1241573
I am using the Grove microphone and the Grove analog-to-digital converter to sample sound. The Grove platform documentation provides the following example C code to read data from the ADC that I am trying to port to Mathematica:
#include <Wire.h>
#define ADDR_ADC121 0x55
#define V_REF 3.00
#define REG_ADDR_RESULT 0x00
#define REG_ADDR_ALERT 0x01
#define REG_ADDR_CONFIG 0x02
#define REG_ADDR_LIMITL 0x03
#define REG_ADDR_LIMITH 0x04
#define REG_ADDR_HYST 0x05
#define REG_ADDR_CONVL 0x06
#define REG_ADDR_CONVH 0x07
unsigned int getData;
float analogVal=0; // convert
void init_adc()
{
Wire.beginTransmission(ADDR_ADC121); // transmit to device
Wire.write(REG_ADDR_CONFIG); // Configuration Register
Wire.write(0x20);
Wire.endTransmission();
}
void read_adc() //unsigned int *data
{
Wire.beginTransmission(ADDR_ADC121); // transmit to device
Wire.write(REG_ADDR_RESULT); // get result
Wire.endTransmission();
Wire.requestFrom(ADDR_ADC121, 2); // request 2byte from device
delay(1);
if(Wire.available()<=2)
{
getData = (Wire.read()&0x0f)<<8;
getData |= Wire.read();
}
Serial.print("getData:");
Serial.println(getData);
delay(5);
Serial.print("The analog value is:");
Serial.print(getData*V_REF*2/4096);
Serial.println("V");
}
The code writes 0x20 to 'register 2'. After some trial and error I found out that the Mathematica equivalent seems to be:
DeviceWrite[i2c, {0,0,32}]
because after that I can read data continuously using:
d = DeviceRead[i2c, 2]; n = d[[1]] * 256 + d[[2]]
Is this the way to set 'registers' on an ADC? Also, what does setting it achieve? The Grove documentation is rather vague on this point.
Thanks,
GijsbertGijsbert Wiesenekker2017-12-08T14:29:04ZBSplineFunction not evaluating as expected in RevolutionPlot3D?
http://community.wolfram.com/groups/-/m/t/1242827
Hello,
Why does the code (shown below) give this error?
> Dot::rect: Nonrectangular tensor encountered.
And how might this code be modified to produce the desired plot?
controlPoints = {{0., 1.48195}, {0.151384, 1.49651}, {0.330883, 1.39382}, {0.488076, 1.2461}, {0.575162, 1.06331}, {0.599079, 0.886118}, {0.547864,
0.698224}, {0.46997, 0.542705}, {0.386957, 0.404801}, {0.285357, 0.28673}, {0.314028, -0.0307762}, {0.202299, -0.0181826}, {0., 0.}};
RevolutionPlot3D[BSplineFunction[controlPoints][t], {t, 0, 1}]Rian Shams2017-12-11T04:51:43ZAvoid error in the DeviceConfigure?
http://community.wolfram.com/groups/-/m/t/1242965
Hi, I am trying to connect an Arduino UNO R3 to a Raspberry Pi and do the blink of the led. The device is connected but when I try to configure the sketche I receive the error messages and I coud not figure out where it is the error. Please help me, Juan
DeviceConfigure[ard, "Upload" -> {Initialization -> "int val = 0;", "Functions" -> <|
"BlinkInvert" -> <|"Code" -> "void blink() {pinMode(13,OUTPUT); digitalWrite(13,val); val \
= !val;}"|>, "BlinkArgument" -> <|"Code" -> "void blink(int pin, int val) {pinMode(pin,OUTPUT); \
digitalWrite(pin,val);}"|>|>}]
KeyExistsQ::invrl: The argument void blink() {pinMode(PIN,OUTPUT); digitalWrite(PIN,val); val = !val;} is not a valid Association or a list of rules.
KeyExistsQ::invrl: The argument void blink(int PIN, int val) {pinMode(PIN,OUTPUT); digitalWrite(PIN,val);} is not a valid Association or a list of rules.
StringJoin::string: String expected at position 1 in void blink() {pinMode(PIN,OUTPUT); digitalWrite(PIN,val); val = !val;}[Code]<>
<>void blink(int PIN, int val) {pinMode(PIN,OUTPUT); digitalWrite(PIN,val);}[Code]
StringJoin::string: String expected at position 3 in void blink() {pinMode(PIN,OUTPUT); digitalWrite(PIN,val); val = !val;}[Code]<><>void blink(int PIN, int val) {pinMode(PIN,OUTPUT); digitalWrite(PIN,val);}[Code]Juan Fuentes2017-12-11T17:40:48Z[✓] Refresh or clear cached CloudObjects[]?
http://community.wolfram.com/groups/-/m/t/1242497
[*cross posted on mathematica.stackexchange.com*](https://mathematica.stackexchange.com/q/161661/5478)
Let's create an API which creates one file each time it is called/accessed:
obj = CloudDeploy[
APIFunction[{}
, Put[$RequesterWolframID
, "testFiles/" <> DateString["ISODateTime"] <> ".txt"
] &
]
, "apiTest"
, Permissions -> "Public"
];
CloudEvaluate@CreateDirectory@"testFiles/";
and let's call it:
URLRead[obj]
CloudObjects["testFiles/"]
URLRead[obj]
CloudObjects["testFiles/"]
[![enter image description here][1]][1]
But this is not true, if you visit a browser interface they will be there:
[![enter image description here][2]][2]
In fact, once you visit it, `CloudObjects` cache changes, but only once:
URLRead[obj]
CloudObjects["testFiles/"]
URLRead[obj]
CloudObjects["testFiles/"]
[![enter image description here][3]][3]
So how to make sure `CloudObjects` returns up to date result?
I am fine with an additional step to flush the cache, I just want it to be possible programmatically.
[1]: https://i.stack.imgur.com/jBXTj.png
[2]: https://i.stack.imgur.com/5WLAs.png
[3]: https://i.stack.imgur.com/9zzA7.pngKuba Podkalicki2017-12-10T13:57:17Z[✓] Solve a system of two rather complicated power equations?
http://community.wolfram.com/groups/-/m/t/1242863
Hi
I am not a Mathematica user, I am just looking for a math package that can solve my problem.
I need to solve a system of two rather complicated power equations, like those in the image below. Here x and z are the unknown variables, all other constants are known. Can Mathematica do that?
But actually I need even more. I will have a set of values for the known constants I and D (A and a are fixed). So I will need not just one solution but a set of solutions for each pair of (I, D). So, if I feed the set of (I,D) pairs into Mathematica, can it produce a set of solutions for me, not just one solution?
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Untitled.png&userId=1242847Lev Dorosinskiy2017-12-11T11:39:37ZAvoid Time Limit Exceeded error in CloudCDF ?
http://community.wolfram.com/groups/-/m/t/1243126
We developed a CloudCDF that gets log events from a Data Drop bin, builds statistical charts and presents them. While the web output has always been on the slower side we proceeded to load historical data with JUN-AUG sitting around 5,000 events / 431kB. When refreshing the CloudCDF to review the results we're now getting the following error with no CDF being displayed...
> {"errorCode": "TimeLimitExceeded", "errorDetails": "1 minute" }
Anyone know what's causing this and how to fix it?Randy Schultz2017-12-11T15:28:18ZMachine learning benchmarking toolkit
http://community.wolfram.com/groups/-/m/t/1242563
Since Wolfram is investing in Machine learning (as I understand using MXNet) and using this nice Wolfram technology
might result in some ML production projects with or without Wolfram technology as a follow-up, a decision must be made on what
hardware infra to choose.
Hewlett Packard created a project (by the HPE Labs) on github that can be used to test several setups.
> Deep Learning Benchmarking Suite Deep Learning Benchmarking Suite
> (DLBS) is a set of command line tools for providing consistent and
> reproducible benchmark experiments on various hardware/software
> combinations. In particular, DLBS provides the following
> functionality:
>
> Implements internally various deep models. Our goal is to provide same
> model implementations for all supported frameworks. Deep models that
> are supported include various VGGs, ResNets, AlexNet and GoogleNet
> models. Benchmarks single node multi GPU configurations. Frameworks
> that are now supported: BVLC Caffe, NVIDIA Caffe, Intel Caffe, Caffe2,
> TensorFlow, MXNet and TensorRT. Supports inference and training
> phases. Can use real data if dataset is available. Else, falls back to
> synthetic data. Supports bare metal and docker environments.
If you think it's useful you can read more on:
[https://github.com/HewlettPackard/dlcookbook-dlbs][1]
[1]: https://github.com/HewlettPackard/dlcookbook-dlbsl van Veen2017-12-11T09:34:16Z[GIF] Lean In
http://community.wolfram.com/groups/-/m/t/1242836
![Spheres in projective space][1]
_Lean In_
A similar idea to [_Fall Out_][2], one dimension up. Now I have a 2-sphere in the 3-sphere which I map to 3-space by extending the line containing a point until it intersects the $w=1$ hyperplane, then inverting in the unit sphere and reflecting through the origin.
The underlying object is just the standard equatorial 2-sphere $(x,y,z,0)$ with $x^2+y^2+z^2=1$, which then gets rotated by $\pi/4$ in the plane spanned by $\cos s (0,0,1,0) + \sin s (1,0,0,0)$ and $(0,0,0,1)$ as $s$ varies from $0$ to $2\pi$.
Here's the code:
inversion[p_] := p/Norm[p]^2;
With[{n = 50, m = 31, d = .01,
cols = Darker[RGBColor[#]] & /@ {"#43DDE6", "#FC5185", "#364F6B"}},
Manipulate[
Graphics3D[
{Sphere[#, .02] & /@
Flatten[
Table[
i * inversion[#1[[1 ;; -2]]/#1[[-1]]] &[
RotationMatrix[π/4, {Cos[s] {0, 0, 1, 0} + Sin[s] {1, 0, 0, 0}, {0, 0, 0, 1}}]
.{Sqrt[1 - z^2] Cos[θ], Sqrt[1 - z^2] Sin[θ], z, 0}],
{i, {-1, 1}}, {θ, 0., 2 π - 2 π/n,
2 π/n}, {z, -1., 1, 2/m}], 2]},
PlotRange -> 1.2, Boxed -> False, ViewPoint -> {0, 5, 0},
ImageSize -> 540, Background -> cols[[-1]],
Lighting -> {{"Point", cols[[1]], 1/2 {Sin[s], 0, Cos[s]}},
{"Point", cols[[2]], 1/2 {-Sin[s], 0, -Cos[s]}}, {"Ambient", cols[[-1]], {0, 5, 0}}}],
{s, 0, 2 π}]
]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=projective5gc.gif&userId=610054
[2]: http://community.wolfram.com/groups/-/m/t/1239487Clayton Shonkwiler2017-12-11T05:12:17ZEdge detect code gives different outputs
http://community.wolfram.com/groups/-/m/t/1242353
I have often noticed that examples of the past when done in newer versions of Mathematica generate inconsistent results. A prime example related to the following post (Character edge finding):
pic = Thinning@Binarize[GradientFilter[Rasterize[Style["\[Euro]",
FontFamily -> "Times"], ImageSize -> 200] // Image, 1]];
pdata = Position[ImageData[pic], 1];
lcp = ListCurvePathPlot[pdata];
This simple piece of code gives different results in Mathematica 9.0, 10.4 and 11.2 with default options. I have posted the results on StackExchange
(click the [link][1] to see).
Note: this is not the only example where I have seen differences.
**To the WRI quality assurance department**:
Can you kindly check why similar functions do not behave the same across different versions ?? I think it is more crucial to establish whether
the built-in functions are working properly rather than releasing more and more functions without appropriate checks.
[1]: https://mathematica.stackexchange.com/questions/161667Ali Hashmi2017-12-09T19:32:04Z[✓] Use a delayed rule to substitute a multi-variable derivative?
http://community.wolfram.com/groups/-/m/t/1242466
I was using a delayed rule to substitute a multi-variable derivative, but syntax error encountered in my second input as the following and the attachments. I am a Newbie. Is there anyone who would like to tell me what's wrong and how to fix it? Thanks a lot!
kc1 = -\!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\(\[Eta][x, t]\)\) - U1 \!\(
\*SubscriptBox[\(\[PartialD]\), \(x\)]\(\[Eta][x, t]\)\) + \!\(
\*SubscriptBox[\(\[PartialD]\), \(y\)]\(
\(\*SubscriptBox[\(\[Phi]\), \(1\)]\)[x, y, t]\)\)
temp1 = kc1 /. {(\[Eta]^(a1_, a2_))[x, t] :> \!\(
\*SubscriptBox[\(\[PartialD]\), \({x, a1}, {t, a2}\)]\((
\*OverscriptBox[\(\[Eta]\), \(^\)] Exp[I\ k \((x - ct)\)])\)\)}Leshan Fisher2017-12-10T01:22:36ZDistributionSmoothing option in Classify with NearestNeighbors Method
http://community.wolfram.com/groups/-/m/t/1241866
I had a need/desire to figure out how the DistributionSmoothing option in Classify really worked when the Method used was NearestNeighbors. After some poking around, I believe I figured it out. Here's conceptually what it does; I suspect it uses code that is several orders of magnitude more efficient. My code is more explanatory purposes only.
Get a list of the classes -- the right answers -- of the training set. Create another "augmentation list" that has one member of each possible class in the training set. Put these two lists together and find their distribution. Call this the "augmented global distribution."
Now get the distribution of the decisions your classifier makes about the neighbors. Call this the "local distribution."
Form a mixture distribution of the local distribution and the augmented global distribution. The weights on the distribution are 1 for the local distribution and s/n for the augmented global distribution where s is the distribution smoothing parameter and n is the number of neighbors you are using.
The idea is that as the distribution smoothing parameter gets bigger, the particular distribution of neighbors in the locality matters less and less and the global distribution matters more. I assume one augments the list to avoid problems (maybe division by zero?) that might occur if the global list had just one class in it.
Here's a simple example.
data = {1 -> True, 2 -> True, 3 -> True, 4 -> False, 5 -> True,
6 -> True, 7 -> False, 8 -> False, 9 -> True};
Now form the augmented distribution and create the augmentedGlobalDistribution using EmpiricalDistribution
augmentedList = Join[Last /@ data, {True, False}]
augmentedGlobalDistribution=EmpiricalDistribution[augmentedList]
Form the local distribution. I'll arbitrarily select person 5 as the individual of interest.
subject=5;
neighbors=3;
nf=Nearest[data];
localDistribution = EmpiricalDistribution[nf[subject, neighbors]]
Now let's form the mixture distribution of the augmented global distribution and the local distribution. I do so by creating a function in which the argument ds represents the data smoothing parameter.
predictedProbability[ds_] :=
MixtureDistribution[{1, ds/neighbors}, {localDistribution,
augmentedGlobalDistribution}]
We now use that to predict the probability that our subject (person 5) will be True when I use distribution smoothing parameters of 0, 1, 2 and 4.
Map[PDF[predictedProbability[#],2]&,{0,1,2,4}]
The answer is
{0.666667, 0.659091, 0.654545, 0.649351}
Now we see what happens when we use Classify with the same distribution smoothing parameters
Map[Classify[data,
Method -> {"NearestNeighbors", "NeighborsNumber" -> neighbors,
"DistributionSmoothing" -> #},
TrainingProgressReporting -> None][subject, "Probabilities"][
True] &, {0, 1, 2, 4}]
We get the same answers! So, is this proof that I have successfully reverse engineered the DistributionSmoothing option? No. But am I confident in my work? Yes. The algorithm makes sense.Seth Chandler2017-12-09T18:56:33Z[✓] One simple equation gets answer, similar one does not?
http://community.wolfram.com/groups/-/m/t/1241519
In Mathematica 11.2, when I try
Solve[{x + y == 12, y == 2 x}, {x}]
I get
{{x -> 4}}
Looks good. But, if I do
Solve[{x + y == 25, y == 4 x}, {x}]
I get
{{ }}
?Anthony Torrero Collins2017-12-08T05:04:11ZOptimize Get["..."] and RAM usage?
http://community.wolfram.com/groups/-/m/t/1242224
Hello everybody,
I have a little issue with my RAM during a Do loop. Within this do loop I use Get to open a file and thereafter to manipulate it. The memory used is increased by 120 every time the loop runs. This is not much but since I run the loop for several thousand times this small value accumulates. I could pin it down to the Get function and I have created a minimal example (see below) with all RAM tricks that I know of (although I assume that some of them are - in this case - not even necessary). Does anybody know what to do?
Unprotect[Out];
Unprotect[In];
$HistoryLength = 0;
Do[
Get[stringValueOfTheFile];
ClearSystemCache[];
Clear[In];
Clear[Out];
Print[MemoryInUse[]];
, {i, 1, 100}];
Thanks in advance
MarkusMarkus Thürmann2017-12-09T12:27:50Z[✓] Plot for numerical integration?
http://community.wolfram.com/groups/-/m/t/1240835
How can I plot a graph and interval table for the following function?
NIntegrate[0.00159155/(x^2 + 0.000025^2), {x, -10, 10, 0.2}, Method ->
{"MultiPanelRule", Method -> {"TrapezoidalRule", "Points" -> 2, "RombergQuadrature" -> False},
"Panels" -> 50}, MaxRecursion -> 0] // QuietMujtaba Mozumder2017-12-06T13:19:59Z[✓] Perform a specific substitution in an expression?
http://community.wolfram.com/groups/-/m/t/1240800
I was trying to substitute the "strain" in an expression with "displacement", and hopes to make it as general as possible in any dimensions. The relationship between the two is:
> e(i,j)=(du(i)/dx(j)+du(j)/dx(i))/2
where e(i,j) and u(i) are function of coordinates.
So I first created two lists, coor={x,y,z} and list={#1,#2,#3}, which are special case for 3D. This two lists can be generated by other function so it can be generalized to other dimensions.
Then, I try to substitute e(i,j) in some test expressions, like this one:
D[e[1,2][x, y, z], y]
But I don't know how to perform such a substitution, I have tried:
D[e[1,2][x, y, z], y] /.
e[i_ , j_] :> ((D[Evaluate[u[i] @@ list], coor[[j]]] +
D[Evaluate[u[j] @@ list], coor[[i]]])/2 &)
which doesn't work. But something like:
D[e[1,2][x, y, z], y] /. e[i_ , j_] :> (Evaluate[u[i] @@ list] &)
works fine. This is not what I want, though. I want to substitute the e(i,j) with derivative of u(i) instead. How can I achieve this?
Thanks in advance!
Edit: fix a mistake in the test expression.Ox Clouding2017-12-07T15:22:52ZBug with Block & Lookup: Scope Variable Leak.
http://community.wolfram.com/groups/-/m/t/1241974
After debugging a large chunk of code, I could identify this [MWE](https://en.wikipedia.org/wiki/Minimal_Working_Example).
ClearAll@test
test[var_String]:= Block[{association},
association = <|"x"-> <|"key01"-> "ok"|>|>[var];
Lookup[association,"key01",{}]
]
If I evaluate:
test["x"]
test["y"]
test["x"]
I get an error evaluating the last `test["x"]`. What is very strange, I expected to find an error just in the evaluation of `test["y"]`.
The same error does not occur if we change from Block to Module. In the Block case, we have some sort of unexpected scope leak.
Looks like a bug in `Lookup`.
Tested in Mathematica version 11.3
[Cross post](https://mathematica.stackexchange.com/questions/161616) in Stack ExchangeRodrigo Murta2017-12-08T21:32:33ZAvoid subsequent calculations to cause lost of prior calculations in nb?
http://community.wolfram.com/groups/-/m/t/1241366
It seems that the only way that I can calculate the attached notebook is by first going into "Evaluate" and then selecting "Quit Kernel" then selecting "Local" and finally press the "Enter" key on my number pad. If I later press the "Enter" key on my number pad, while in the notebook, I loose my evaluations and then need to through the "Evaluate" and then selecting "Quit Kernel" procedure again.
It appears that the first top down calculation works fine, but any additional calculations really seems to mess the notebook up. Additionally, I am getting a "Set::write: Tag Function in (0&)[0.000263158] is Protected" message as well.
Could someone please tell me what I am doing wrong.
Thanks,Mitchell Sandlin2017-12-07T19:14:34Z[✓] Simplest method for computing cross correlation?
http://community.wolfram.com/groups/-/m/t/1241550
I have two lists, x and y, of equal length, Nx, and I wish to construct the cross-correlation of the two. To compute the autocorrelation of just x (or y) I simply used
Rxx = CorrelationFunction[x, {Nx - 1}]
For the cross-correlation, I first attempted to construct a function using the following:
Rxy[n_] = Sum[x[[m]]*y[[m + n]], {m, 1, Nx - n}],
where n denotes the prescribed lag. This resulted in an error message "The expression m cannot be used as a part specification."
I'm not sure as to what this error means. Also, is there a simple way to use the ListConvolve function to create the desired cross-correlation? (I'm a bit confused by the description at http://reference.wolfram.com/language/ref/ListConvolve.html)Paul Fishback2017-12-08T11:32:06ZExport a PNG file with ColorMap and RawData?
http://community.wolfram.com/groups/-/m/t/1241941
Some database for machine learning, like VOC dataset, use .PNG file to store information. They store information in 0~255, and display it by using ColorMap.
I import it by using this code:
data=Import[path, "RawData"]
cmap=Import[path, "ColorMap"]
But I cannot find a way to export a PNG file in this format. A .PNG file in this format is included.Zhang Yanbo2017-12-08T14:38:40ZWhere can I get MRAALink version 1.0.5 (or higher)?
http://community.wolfram.com/groups/-/m/t/1231695
Hi,
I am getting errors with Mathematica 11.0.1 on Raspbian with kernel 4.9.59-v7+. These are related to the supplied version of MRAALink which is 1.0.2 and version 1.0.5 (or higher?) resolves these errors (see other discussions in this group). PackletUpdate however says that no newer version of MRAALink is available. Where can I get version 1.0.5 (or higher)?
Thanks,
GijsbertGijsbert Wiesenekker2017-11-28T00:07:25ZSolve a system of equations?
http://community.wolfram.com/groups/-/m/t/1241479
I need to solve this apparently simple system of equations in Mathematica, but it gives me an error message, that Equations may not give solutions for all "solve" variables. The command is
sol = Solve[{x1 == x A1/(x A1 + y A3), x2 == x A2/(x A2 + y A4),
x3 == y A3/(x A1 + y A3), x4 == y A4/(x A2 + y A4),
x1 + x2 + x3 + x4 == 2, x + y == 1}, {x1, x2, x3, x4, x, y}]
Any help is appreciated.Alex Token2017-12-08T08:28:45Z$5K Mathematica Machine
http://community.wolfram.com/groups/-/m/t/1241177
Suppose you had \$5K to spend on a computer that was to be devoted to computation-intensive Mathematica-based explorations. What features would you look for? Is there a particular computer you'd recommend? Extra credit if the recommended machine costs less than \$5K.
Thanks in advance for any insight.Scott Guthery2017-12-07T15:53:33ZDynamic List Plot of Serial Input in Mathematica via Arduino Serial.Print()
http://community.wolfram.com/groups/-/m/t/1241353
Hey everybody,
I'm trying to read the serial input of my USB Port into Mathematica dynamically to create a live ListPlot.
My Arduino Uno sends strings in the format of a pair via Serial.print() to the Serial Port:
![\]\[1\]][1]
(the constant Output "{0,1}\n" is just a test value)
In Mathematica 11 I connect to the Serial Port via DeviceOpen[] and start a Task that reads out the Buffer Data on my Arduino and converts it to a string.
Then I split that string into substrings at any "\n" to get pairs and interpret them in Wolfram Language as a pair.
I add these pairs to a list and then Plot that list dynamically via ListLinePlot[].
![\]\[2\]][2]
My Problem is that Mathematica doesn't read that data correctly and mostly mashes up the data and crashes.
It would be great if you guys could help me out with that!
Thanks!
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=arduino.JPG&userId=1241339
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=8486signaltransfer.JPG&userId=1241339Franz Biermann2017-12-07T18:41:19Z[✓] Join solutions to the Scrödinger Equation for a barrier potential?
http://community.wolfram.com/groups/-/m/t/1240280
I want to obtain the the solutions to the time independent Schrödinger Equation for a barrier potential. I have created three equations:
tise1 = -\[HBar]^2/2 m D[\[Psi]1[x], {x, 2}] == e0 \[Psi]1[x]
tise2 = -\[HBar]^2/2 m D[\[Psi]2[x], {x, 2}] == (e0 - v0) \[Psi]2[x]
tise3 = -\[HBar]^2/2 m D[\[Psi]3[x], {x, 2}] == e0 \[Psi]3[x]
and the boundary conditions
bc = {\[Psi]1[0] == \[Psi]2[0], \[Psi]2[a] == \[Psi]3[a],
D[\[Psi]1[x], x] == D[\[Psi]2[x], x] /. x -> 0,
D[\[Psi]2[x], x] == D[\[Psi]3[x], x] /. x -> a}; ic = {}
(I intended to use ic to remove "left moving" waves right of the potential (x>a), but I could no figure out how to do this)
Next I used
sol = DSolve[
Join[{tise1, tise2, tise3}, bc, ic], {\[Psi]1, \[Psi]2, \[Psi]3},
x]
But the results are overwhelming and as far as I can tell: wrong. I would like to be able to get the wave function as an piecewise concatenation of psi 1-3 to add the time development and to calculate transmission and reflection rates.
Hopefully this makes sense. Any help (or pointers to such) will be appreciated.
/Mogensjallberg2017-12-05T22:01:45ZAccelerate computations using GPU?
http://community.wolfram.com/groups/-/m/t/1237212
Hi,
I am trying to accelerate computation using GPU. I started with the textbook example
Needs["CUDALink`"]
ListLinePlot[
Thread[List[CUDAFoldList[Plus, 0, RandomReal[{-1, 1}, 500000]],
CUDAFoldList[Plus, 0, RandomReal[{-1, 1}, 500000]]]]]
This code should use GPU to accelerate the computation.
Then for comparison, I tried to generate similar result with
ListLinePlot[
Thread[List[FoldList[Plus, 0, RandomReal[{-1, 1}, 500000]],
FoldList[Plus, 0, RandomReal[{-1, 1}, 500000]]]]]
In both cases it took about 4 sec. to finish the computation i.e. there was no significant difference in time required to get the result. Why?Rafael Petrosian2017-12-03T01:43:49ZFITS Import incompatible between 11.2 and earlier versions
http://community.wolfram.com/groups/-/m/t/1239196
I was happy to note that the FITS Im/Export got some attention in the lates Update to Version 11.2. However, Import is now incompatible to its earlier incarnations. I am not sure wether I discovered all changes in its behavior and I am asking here for any experience others got with Import of FITS files.
This is what I found:
- Header, i.e. Metadata, information is now imported as an Association with the first key "GENERAL INFORMATION" . This is far from any FITS standard. Compare the header import from 11.1.1 and 11.2:
**11.1.1**
{"SIMPLE" -> {True, ""}, "BITPIX" -> {-32, ""}, "NAXIS" -> {4, ""},
"NAXIS1" -> {121, ""}, "NAXIS2" -> {121, ""}, "NAXIS3" -> {221, ""},
"NAXIS4" -> {1, ""}, "DATAMIN" -> {0., ""}, "DATAMAX" -> {0., ""},
"BUNIT" -> {"K (Tmb)", ""}, "CTYPE1" -> {"RA---GLS", ""},
"CRVAL1" -> {306.861, ""}, "CDELT1" -> {-0.00166667, ""},
"CRPIX1" -> {61.6741, ""}, "CROTA1" -> {0., ""},
"CTYPE2" -> {"DEC--GLS", ""}, "CRVAL2" -> {37.38, ""},
"CDELT2" -> {0.00166667, ""}, "CRPIX2" -> {61.5654, ""},
"CROTA2" -> {0., ""}, "CTYPE3" -> {"VRAD", ""}, "CRVAL3" -> {0., ""},
"CDELT3" -> {500., ""}, "CRPIX3" -> {101., ""},
"CROTA3" -> {0., ""}, "CTYPE4" -> {"", ""}, "CRVAL4" -> {1., ""},
"CDELT4" -> {1., ""}, "CRPIX4" -> {1., ""}, "CROTA4" -> {0., ""},
"OBJECT" -> {"S106", ""}, "RA" -> {306.861, "Right Ascension"},
"DEC" -> {37.38, "Declination"}, "EQUINOX" -> {2000., ""},
"LINE" -> {"CII", ""}, "ALTRPIX" -> {101., ""},
"ALTRVAL" -> {1.90054*10^12, ""}, "RESTFREQ" -> {1.90054*10^12, ""},
"VELO-LSR" -> {0., ""}, "VELREF" -> {257, ""},
"SPECSYS" -> {"LSRK", ""}, "BMAJ" -> {0.00416667, ""},
"BMIN" -> {0.00416667, ""}, "BPA" -> {0., ""},
"ORIGIN" -> {"GILDAS Consortium", ""},
"DATE" -> {"2017-06-01T10:55:26.668", "Date written"}}
**11.2**
<|"GENERAL INFORMATION" -> <|"SIMPLE" -> True, "BITPIX" -> -32,
"NAXIS" -> 4, "NAXIS1" -> 121, "NAXIS2" -> 121, "NAXIS3" -> 221,
"NAXIS4" -> 1, "DATAMIN" -> 0., "DATAMAX" -> 0.,
"BUNIT" -> "K (Tmb)", "CTYPE1" -> "RA---GLS", "CRVAL1" -> 306.861,
"CDELT1" -> -0.00166667, "CRPIX1" -> 61.6741, "CROTA1" -> 0.,
"CTYPE2" -> "DEC--GLS", "CRVAL2" -> 37.38, "CDELT2" -> 0.00166667,
"CRPIX2" -> 61.5654, "CROTA2" -> 0., "CTYPE3" -> "VRAD",
"CRVAL3" -> 0., "CDELT3" -> 500., "CRPIX3" -> 101., "CROTA3" -> 0.,
"CTYPE4" -> Missing["NotAvailable"], "CRVAL4" -> 1.,
"CDELT4" -> 1., "CRPIX4" -> 1., "CROTA4" -> 0., "OBJECT" -> "S106",
"RA" -> 306.861, "DEC" -> 37.38, "EQUINOX" -> 2000.,
"LINE" -> "CII", "ALTRPIX" -> 101., "ALTRVAL" -> 1.90054*10^12,
"RESTFREQ" -> 1.90054*10^12, "VELO-LSR" -> 0., "VELREF" -> 257,
"SPECSYS" -> "LSRK", "BMAJ" -> 0.00416667, "BMIN" -> 0.00416667,
"BPA" -> 0., "ORIGIN" -> "GILDAS Consortium",
"DATE" -> "2017-06-01T10:55:26.668"|>|>
Note that the comment entry of each header is is now omitted (last entry "DATE" This violates the FITS standard as far as I understand? In any case it breaks my code that expects to import a List and not an Association - and yes I know that I can use Normal to transform it into a List again. I didn't check yet how the header is imported if data is stored in a more complex arrangement, such as Bintable or another Extension format.
- Data is imported in reverse order now. Image and RawData Import now return the same row ordering. I don't know what the standard order should be, but it changed after 11.2. As an example I Import an array of spectra:
11.1.1
In[9]:=Dimensions[raw]
Out[9]:={1, 1, 221, 121, 121}
In[10]:=raw[[1, 1, All, 50, 50]]
Out[10]:= {0.125237, 2.99011, 0.571144, -0.834969, 1.56174, 0.110322, -1.4104, \
-2.62194, -1.9974, 1.81346, 1.41345, -0.346708, -0.284448, 1.31853, \
-1.36181, -3.43505, 2.01738, 3.3406, -0.353997, 3.28855, -0.4002, \
-0.415156, 2.57086, -0.826749, -0.493768, -1.06639, -0.795575, \
0.438714, 1.41906, -1.45034, -1.13682, -1.06962, 0.349537, -1.69687, \
-0.618968, -1.31552, -1.63609, -1.14806, -1.78705, -1.59089, \
-0.0172433, -1.34023, -1.68296, -0.169548, 0.525515, 2.61707, \
-0.10389, 1.23272, -1.37291, 2.35375, 1.26516, -0.9361, -2.47334, \
0.319303, 0.574864, -1.37799, 2.33915, 2.38415, -0.855974, 0.500247, \
1.93797, -0.510813, -1.4609, 1.37657, -1.31001, 1.82468, -0.0288664, \
0.788793, -0.0313442, 1.0192, 0.661234, -0.551474, 3.03574, \
-0.258694, 0.83997, -0.590292, -0.164056, -0.675589, 1.22346, \
1.87058, -0.421079, -0.670318, 0.758016, 1.17182, -1.83596, 0.130186, \
-1.47637, 0.0714399, -0.381047, -0.654595, 0.337103, 0.0541637, \
3.54652, 0.473411, -0.751777, 2.00137, 1.23871, 0.964236, 0.697787, \
0.745029, 1.64881, 3.73721, -1.57351, 0.0654506, 1.01008, -3.37733, \
0.536895, 1.05536, -2.57754, -0.439541, -1.92688, -1.43538, \
-0.580122, -2.33661, 1.18908, -0.270191, -1.23731, -1.61967, \
-2.18623, -1.54892, -2.25664, -1.60237, -1.10626, -3.27524, -2.8534, \
-1.30801, -2.94565, -1.62026, -1.18614, -1.68366, -3.44239, -4.29097, \
0.139907, 1.39606, 0.885509, 1.06719, -0.0184753, -1.556, 1.02081, \
-0.15279, 1.59421, -0.582037, 0.377889, -0.0525626, 1.52673, \
0.449664, 0.628198, 2.56478, 1.04696, -0.246007, -1.73447, 0.984217, \
1.40674, -1.03528, 1.74808, 0.661529, -1.55615, 2.12005, 0.0215735, \
-0.843181, -0.187671, 2.10022, 1.94109, 0.461266, -0.836785, \
-1.85344, 1.4057, -1.1845, -0.0455038, -2.07055, -1.30267, -0.957898, \
-0.813964, 0.0770546, 1.1605, -0.0788292, 0.352559, -2.4903, \
-0.0513624, 0.927214, -1.23293, -0.846625, -2.09944, -0.909728, \
-0.178735, -0.756856, -0.0954211, -2.28924, -0.616761, -0.295874, \
0.97779, -0.325473, 1.3985, 0.176696, -0.936313, 0.919589, 2.14291, \
-0.287233, 1.11923, 1.55756, 0.128433, 0.739541, -0.211153, 0.56651, \
2.30676, 0.714307, 1.81921, 0.0436757, 0.384643, 0.223706, 1.79563, \
-0.512, 1.53679, 1.84418, 0.788868, 2.69285, 0.688162, 1.14756, \
-0.599565, -1.12756, 0.227808}
**11.2**
In[11]:= raw[[1, 1, All, 50, 50]]
Out[11]= {0.741499, 2.69608, -0.835699, 0.260684, 0.344929, \
-0.862212, 0.103039, -0.406144, 1.25696, 2.21517, -3.61728, \
-0.390149, -0.20015, -0.221925, -0.133629, -0.127833, -0.537916, \
-1.6329, 0.529082, 2.89574, 2.174, 0.509376, -0.12798, -2.91033, \
-0.936878, 1.72893, -0.144214, -1.6564, -0.203739, 1.31158, 0.482649, \
-2.29575, 1.49968, -1.43943, -0.907162, 2.33743, -0.134048, -1.52299, \
0.700724, -1.32794, 0.0540263, -0.0130849, -1.3927, -0.358867, \
0.457883, 0.920364, 0.0981134, 0.398595, 2.10525, -1.26789, \
-0.120008, 1.87544, 1.49796, 1.14598, -0.445654, 0.0828433, -0.5025, \
0.48467, -0.903544, 0.721465, -1.19323, 1.8576, -0.913446, \
-0.0233543, -0.130562, 0.171933, -1.76813, 1.22534, -0.769345, \
0.596699, -1.53008, -0.806187, 0.376273, 0.274861, 0.879051, \
-0.285103, 0.652643, -2.05536, -1.18484, 1.23708, -0.524947, \
-1.10875, 0.632588, 0.362561, 0.521122, 1.09359, 2.34802, 0.219165, \
0.528764, 3.89038, 2.3092, 4.25087, 2.91008, 3.86056, 4.43583, \
5.34523, 3.33701, 5.04292, 6.16093, 3.11196, 4.95334, 3.44107, \
3.13834, 1.72268, 1.4871, 2.09813, -1.24582, 1.52399, 1.33164, \
-1.41426, -0.438202, 1.09399, 1.99072, -0.0511786, 1.6797, 1.81019, \
0.234106, 0.0070522, -0.191584, -1.71418, 0.300965, 1.56744, 2.86724, \
-0.710091, -0.042246, 0.0861327, 0.404054, 0.245493, 1.15148, \
-0.107975, -0.609298, -0.358749, -0.93885, -0.575624, 1.58488, \
0.605153, -0.148833, 1.31476, 0.886797, -0.500806, 0.690805, 1.55135, \
-2.82947, -1.44928, 0.0264999, 0.0159517, 0.381241, -0.710363, \
0.308564, -0.362335, 0.384097, 0.0797061, -0.522967, -2.15822, \
0.146816, 1.26085, 1.6938, 0.86811, 1.65988, -0.939591, -0.786369, \
-0.473823, 0.299186, 2.18688, -0.564252, -1.95808, -0.297, \
-0.00392977, 0.0266746, -0.849348, 1.03588, 0.392564, 0.383135, \
0.955122, -0.398982, 0.96028, 0.159508, -0.806305, -0.292513, \
0.168193, 1.60123, 0.0350197, -2.45768, -0.809964, -0.966695, \
0.389624, -0.296024, 1.07444, -0.276236, -0.0449804, 0.135233, \
0.994279, -0.915011, -0.196694, 0.568144, -0.0751389, 0.0356748, \
-1.49772, -2.33957, 2.12178, -0.122009, 1.63197, 1.28452, -1.27409, \
1.67394, -0.64527, -1.91461, 0.0593593, -0.0333713, -0.355916, \
0.164881, 1.38631, 2.90664, 1.8102, -0.422445, 0.256066, 0.393217, \
1.07279, 2.3621, -0.935344, 1.38919}
In[12]:= raw[[1, 1, All, -50, 50]]
Out[12]:= {0.125237, 2.99011, 0.571144, -0.834969, 1.56174, 0.110322, -1.4104, \
-2.62194, -1.9974, 1.81346, 1.41345, -0.346708, -0.284448, 1.31853, \
-1.36181, -3.43505, 2.01738, 3.3406, -0.353997, 3.28855, -0.4002, \
-0.415156, 2.57086, -0.826749, -0.493768, -1.06639, -0.795575, \
0.438714, 1.41906, -1.45034, -1.13682, -1.06962, 0.349537, -1.69687, \
-0.618968, -1.31552, -1.63609, -1.14806, -1.78705, -1.59089, \
-0.0172433, -1.34023, -1.68296, -0.169548, 0.525515, 2.61707, \
-0.10389, 1.23272, -1.37291, 2.35375, 1.26516, -0.9361, -2.47334, \
0.319303, 0.574864, -1.37799, 2.33915, 2.38415, -0.855974, 0.500247, \
1.93797, -0.510813, -1.4609, 1.37657, -1.31001, 1.82468, -0.0288664, \
0.788793, -0.0313442, 1.0192, 0.661234, -0.551474, 3.03574, \
-0.258694, 0.83997, -0.590292, -0.164056, -0.675589, 1.22346, \
1.87058, -0.421079, -0.670318, 0.758016, 1.17182, -1.83596, 0.130186, \
-1.47637, 0.0714399, -0.381047, -0.654595, 0.337103, 0.0541637, \
3.54652, 0.473411, -0.751777, 2.00137, 1.23871, 0.964236, 0.697787, \
0.745029, 1.64881, 3.73721, -1.57351, 0.0654506, 1.01008, -3.37733, \
0.536895, 1.05536, -2.57754, -0.439541, -1.92688, -1.43538, \
-0.580122, -2.33661, 1.18908, -0.270191, -1.23731, -1.61967, \
-2.18623, -1.54892, -2.25664, -1.60237, -1.10626, -3.27524, -2.8534, \
-1.30801, -2.94565, -1.62026, -1.18614, -1.68366, -3.44239, -4.29097, \
0.139907, 1.39606, 0.885509, 1.06719, -0.0184753, -1.556, 1.02081, \
-0.15279, 1.59421, -0.582037, 0.377889, -0.0525626, 1.52673, \
0.449664, 0.628198, 2.56478, 1.04696, -0.246007, -1.73447, 0.984217, \
1.40674, -1.03528, 1.74808, 0.661529, -1.55615, 2.12005, 0.0215735, \
-0.843181, -0.187671, 2.10022, 1.94109, 0.461266, -0.836785, \
-1.85344, 1.4057, -1.1845, -0.0455038, -2.07055, -1.30267, -0.957898, \
-0.813964, 0.0770546, 1.1605, -0.0788292, 0.352559, -2.4903, \
-0.0513624, 0.927214, -1.23293, -0.846625, -2.09944, -0.909728, \
-0.178735, -0.756856, -0.0954211, -2.28924, -0.616761, -0.295874, \
0.97779, -0.325473, 1.3985, 0.176696, -0.936313, 0.919589, 2.14291, \
-0.287233, 1.11923, 1.55756, 0.128433, 0.739541, -0.211153, 0.56651, \
2.30676, 0.714307, 1.81921, 0.0436757, 0.384643, 0.223706, 1.79563, \
-0.512, 1.53679, 1.84418, 0.788868, 2.69285, 0.688162, 1.14756, \
-0.599565, -1.12756, 0.227808}
I am not asking how to correct this - I can do it. I am curious on why this was implemented and what else had been changed. I would also like to see a mentioning of such changes in the Documentation. Any other experiences so far?Markus Roellig2017-12-04T17:19:55Z