Community RSS Feed
https://community.wolfram.com
RSS Feed for Wolfram Community showing any discussions in tag Wolfram Language sorted by activeCan't I use the `ReplaceAll` function to modify a network layer ?
https://community.wolfram.com/groups/-/m/t/2098159
I was reading a paper mentioning the use of a neural network model available in the Wolfram neural repository. The authors explained that they modified the model to use the average function in the pooling layers instead of the max function.
I naïvely thought I could do the same by just applying the rule `Max -> Mean` to all pooling layers to get the same result, but I didn't succeed.
Here is the simplest possible example I could come up with to show you what I mean :
LinearLayer[2] /. 2 -> 3
Why doesn't this instruction return a LinearLayer with three outputs instead of two ? I feel like I'm missing something obvious but I don't see it :-/Lucien Grondin2020-10-20T10:41:43ZHow to better perform this operation within a mapping?
https://community.wolfram.com/groups/-/m/t/2098463
Hi folks,
In the middle of another mapping: I am performing Round and ToString on #[[2]], and then if that result ends in "." I am appending a "0%" otherwise just "%".
Now to accomplish this I've placed the modification in a List, then used map to force it into the If[] statement, then of course I have to use Part to take it out of a list at the end. How is this done without the use of List?
(If[StringPart[#, -1] == ".", # <> "0%", # <> "%"] & /@ {ToString[
Round[100*#[[2]], 0.1]]})[[1]]Richard Frost2020-10-20T08:31:54ZUNET: neural network for 2D & 3D image segmentation w/ medical examples
https://community.wolfram.com/groups/-/m/t/1646303
# UNET [![DOI](https://zenodo.org/badge/137186334.svg)](https://zenodo.org/badge/latestdoi/137186334) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues)
----------
![Automated 3D muscle segmentation using UNET / RESNET using DIXON MRI data][17]
A package to generate and train a UNET deep convolutional network for 2D and 3D image segmentation.
Some code was based on [work][1] by [@Ali Hashmi][at0], which was also dicussed in [this post][2]
The full version of the toolbox can be found on my [github page][3].
* [Information](#information)
* [Install toolbox](#install-toolbox)
* [Using the toolbox](#using-the-toolbox)
* [Functionality](#functionality)
* [Visualization](#visualization)
* [Example](#example)
## Information
UNET is developed for [Mathematica](https://www.wolfram.com/mathematica/).
It contains the following toolboxes:
- UnetCore
- UnetSupport
Documentation of all functions and their options is fully integrated in the Mathematica documentation.
The toolbox always works within the latest version of Mathematica and does not support any backward compatibility.
All code and documentation is maintained and uploaded to github using [Workbench](https://www.wolfram.com/workbench/).
## Install toolbox
Install the toolbox in the Mathematica UserBaseDirectory > Applications.
FileNameJoin[{$UserBaseDirectory, "Applications"}]
## Using the toolbox
The toolbox can be loaded by using <<UNET`
The notbook ``UNET.nb`` shows examples of how to use the toolbox on artificially generated 2D data.
There are also examples how to visualize the layer of your trained network and how to visualize the training itself.
## Functionality
The network supports multi channel inputs and multi class segmentation.
* UNET generates a UNET convolutional network.
* 2D UNET
![UNET 2D][4]
* 3D UNET
![UNET 3D][5]
* Loss Layers: Training the data is done using three loss layers: a SoftDiceLossLayer, BrierLossLayer and a CrossEntropyLossLayer.
![SoftDiceLossLayer, BrierLossLayer and a CrossEntropyLossLayer][6]
* Convolution Blocks: The toobox contains five different convolution blocks that build up the network: [UNET][7], UResNet, [RestNet][8], UDenseNet, [DensNet][9].
![Convolution blocks][10]
* SplitTrainData splits the data and labels into training, validation and test data.
![split train Data][11]
* TrainUNET trains the network.
![Train UNET][12]
## Visualization
* Visualize the network and results.
* Visualize the features of the layers.
![Visualize layer features][13]
* Visualize the results.
![Visualize the results][14]
* Animate the training process.
![UNET 2D animation][15]
![UNET 3D animation][16]
## Example
* Example: 3D segmentation of lower legg muscles using MRI data.
![Automated 3D muscle segmentation using UNET / RESNET using DIXON MRI data][17]
[1]: https://github.com/alihashmiii/UNet-Segmentation-Wolfram
[2]: https://community.wolfram.com/groups/-/m/t/1341081?p_p_auth=w8PIeeiA
[3]: https://github.com/mfroeling
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=UNET2D.PNG&userId=1332602
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=UNET3D.PNG&userId=1332602
[6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Loss.PNG&userId=1332602
[7]: https://arxiv.org/abs/1505.04597
[8]: https://arxiv.org/abs/1512.03385
[9]: https://arxiv.org/abs/1608.06993
[10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=convblocks.PNG&userId=1332602
[11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Split.PNG&userId=1332602
[12]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Train.PNG&userId=1332602
[13]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Visualize1.PNG&userId=1332602
[14]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Visualize2.PNG&userId=1332602
[15]: https://community.wolfram.com//c/portal/getImageAttachment?filename=amin0-v2.gif&userId=1332602
[16]: https://community.wolfram.com//c/portal/getImageAttachment?filename=amin4-v2.gif&userId=1332602
[17]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Muscle_Segmentation.jpg&userId=1332602
[at0]: https://community.wolfram.com/web/alihashmi87Martijn Froeling2019-04-03T20:01:26ZUsing Dynamic variables
https://community.wolfram.com/groups/-/m/t/2097581
I would like to know how to do this sum t+anynumber , where t is "Dynamic[Clock[{0, 20, 1}, 20]]"
I have realized that t is not considered a number (NumericQ[t] is False).Ana Squadri2020-10-19T21:34:25ZError message?
https://community.wolfram.com/groups/-/m/t/2096582
The error message is:
"Why the Beep? There was a syntax error on the line 767 of the cell expression. The error was: Ce"
I do not know how to go about fixing this please help as I am new to Wolfram!
The files in question are attached below.
Help is much appreciated!Nathan Stronkowsky2020-10-16T19:33:54ZProblem with 1 InverseLaplaceTransform[] using Mathematica 11.3
https://community.wolfram.com/groups/-/m/t/2097876
Hello,
I have problems with one special InverseLaplaceTransform.
Mathematica 11.3 doesn't solve it.
Have I done any mistakes?
Thanks
Leo
&[Wolfram Notebook][1]
[1]: https://www.wolframcloud.com/obj/7d17afac-0a7a-4546-8ebb-a34e797fabf7Leo Baumann2020-10-19T23:51:11ZIndexed variables are not working
https://community.wolfram.com/groups/-/m/t/2097451
As seen in code below, I've redefined the Subscript notation to mean Indexed notation. I'm getting a strange error when finding limits of the function shown in the code. Anyone has any idea what I'm doing wrong?
&[Wolfram Notebook][1]
[1]: https://www.wolframcloud.com/obj/7820b119-999b-41b0-a43a-aae1d590b1e9Siddhesh Ambhire2020-10-18T23:06:34ZPossible error? Simple Limit discrepancy between W|A and Mathematica
https://community.wolfram.com/groups/-/m/t/2096424
![The error][1]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=aaaa.png&userId=1797413
It's very straight-forward; the same piece of code (presumably interpreted the same way between both) outputs a different answer. I did the limit with polar coordinates and the answer is, indeed, 1/4.
If you know what may have happened here, let me know.Agustin Covarrubias2020-10-16T18:43:50ZMemory related problem, using ParallelTable[]
https://community.wolfram.com/groups/-/m/t/2096831
I have the following code:
\[Alpha] = 10^6;
L = Total@*Map[Length];
\[DoubleStruckCapitalT][i_, j_] := Binomial[i, j - 1];
L[ParallelTable[
If[TrueQ[
EvenQ[\[DoubleStruckCapitalT][n, k]] && \[DoubleStruckCapitalT][
n, k] != 0], {n, k}, Nothing], {n, 0, \[Alpha] - 1}, {k,
1, \[Alpha]}] //. {} -> Nothing]
But this code gives an error memory message, how can I edit my code such that I want to compute this code for large values of `\[Alpha]`?Jan Eerland2020-10-17T17:05:28ZPlot parametric functions in 3D?
https://community.wolfram.com/groups/-/m/t/2097801
I did a 2D plot of the following equation using Mathematica. Could some help me with the right command in Mathematica to convert the output into a 3D model?
K0=(K1*(α-μ)*((α*μ)-μ-2))/(2*(α+1)*〖(μ+1)〗^2 )
J=K0//.{K1→1,μ→0.02};
L=K0//.{K1→1,μ→0.05};
M=K0//.{K1→1,μ→0.1};
Plot[{J,L,M},{α,0,10},PlotRange→{{-0.5,10},{-1,1.}},PlotStyle→{{Dashed,Blue},{Dashing,Black},{Dashed,Orange},AspectRatio→1.,ImageSize→Large]S Long2020-10-19T07:37:24Z3d Compare past and future generations of the Wolfram models
https://community.wolfram.com/groups/-/m/t/2097827
**[View this post in Wolfram Cloud Notebook format][1]**
Viewing events in 3d on node level to compare the past and future generations of the Wolfram models
========================================================================
We created a new feature to the gigabrain.io physics 3d explorer. It features a comparison between final generations of the current, previous and future generation
Color code explanations in the 3d viewer of the generation comparison
---------------------------------------------------------------------
The 3d viewer's node colors are coded as following:
- Red = Node is found only in previous generation
- Light red = Node is found in previous and current but not the next generation
- Blue Magenta = Node is found in all 3 previous, current and next generation
- Light green = Node is found in current and next but not the previous generation
- Green = Node is found only in next generation
Wolfram model final states as image list
----------------------------------------
Below is a comparison of the event states in Wolfram SetReplace project.
Here we use the Wolfram Model wm3147.
Let's compare the images with the final states using the StatesPlotsList.
ResourceFunction["WolframModel"][{{{1, 1, 2}, {3, 4, 5}} -> {{3, 3, 6}, {1, 3, 2}, {7, 1, 3}, {7, 8, 2}}}, {{1, 1, 1}, {1, 1, 1}}, 4 ][ "StatesPlotsList",VertexLabels -> Automatic, ImageSize -> 100]
![Generations output][2]
Comparing generations in 3d viewer
----------------------------------
**[Click to See model 3147 generation 3 comparison in 3d viewer][3]**
To compare the generation 3 with the 3d viewer we can use the link below and we get the image below. In the user interface you can change the mode by clicking on the mode button. Default mode is for a single graph the next mode is the generation comparison and the third mode is to download the graph as a OBJ 3d file.
![3d Generation comparison][4]
In this graph the Current generation is 3 and previous is 2 and next is 4. For reference the generations are below.
Magenta Nodes 1, 2 and 3 are found in generations 2, 3 and 4.
Light red Node 4 is not in the generation 4 but can be found in 3 and 2.
Light green Nodes 5, 6 and 7 are created in current generation and also present in next generation.
Green Nodes 8, 9, 10, 11, 12 and 13 are found only in generation 4.
![Generations 2 3 4][5]
**[Click to See model 3147 generation 4 comparison in 3d viewer][6]**
When changing the view to the next generation 4 we get the image below.
![3d Generation comparison 2][7]
In this graph the current generation is 4 and previous is 3 and next is 5 . For reference the generations are below.
Magenta Nodes 1, 2, 3, 5, 6 are found in generations 3, 4 and 5.
Light red Node 7 is not in the generation 5 but can be found in 4 and 3.
Light green Nodes 8,9,10,11,12,13 are created in current generation 4 and also present in next generation 5.
Green Nodes 14,15,16,17,18,19 are found only in the next generation 5.
![Generations 3 4 5][8]
The final generation comparison does not take account the single events that produce the final states. We can see a full comparison of the events that produced the states with the EventsStatesPlotsList.
The documentation says about the graphs: Here the dotted gray edges are the ones about to be deleted, whereas the red ones have just been created.
ResourceFunction["WolframModel"][{{{1, 1, 2}, {3, 4, 5}} -> {{3, 3, 6}, {1, 3, 2}, {7, 1, 3}, {7, 8, 2}}}, {{1, 1, 1}, {1, 1, 1}}, 4 ][ "EventsStatesPlotsList",VertexLabels -> Automatic, ImageSize -> 100]
![Event states][9]
Events to produce the generation 3. Nodes with red lines are created.
![Event State 1][10]
Events to produce the generation 4. Here we see the removal of the node 4 with two dotted gray lines.
![Event State 2][11]
Events to produce the generation 5. Here we see the removal of the node 7 with two dotted gray lines.
![Event State 3][12]
Conclusion
==========
As a conclusion this shows that the comparison of the final generations can visually show in what areas the new nodes are created and in what areas the nodes are being deleted. But it does not show the full event graph of how the events are produced.
Problems
========
- The viewer does not show events differently that have first removed a node and later on added the node again in the same generation. It only compares the differences of the final generations.
- Currently the 3d viewer does not handle all types of Wolfram models, like single-element models wm161, model with multiple rules wm4486
- The model calculation is done by Javascript and does not use Wolfram language. By the cause of this the rule choosing is not available in the 3d viewer and the resulting event numbering might differ.
- We use the name Wolfram model as defined in SetReplace Project: "A more interesting case (which we call a Wolfram model) is one where the set elements are related to each other. Specifically, we can consider a set of ordered lists of atomic vertices; in other words, an ordered hypergraph. " Although the implementation is made currently with Javascript's own implementation and not the SetReplace package.
[1]: https://www.wolframcloud.com/obj/tuomas0/Published/Compare_Generations_in_3d_wm3147.nb
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Generationsout1.png&userId=2053745
[3]: http://gigabrain.io/physics/index.html?rule=%7B%7B%7B1,1,2%7D,%7B3,4,5%7D%7D-%3E%7B%7B3,3,6%7D,%7B1,3,2%7D,%7B7,1,3%7D,%7B7,8,2%7D%7D%7D&init=%7B%7B1,1,1%7D,%7B1,1,1%7D%7D&steps=3&modelId=193&modeType=1
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=gigabrainGeneration3comparison.png&userId=2053745
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Generations1.png&userId=2053745
[6]: http://gigabrain.io/physics/index.html?rule=%7B%7B%7B1,1,2%7D,%7B3,4,5%7D%7D-%3E%7B%7B3,3,6%7D,%7B1,3,2%7D,%7B7,1,3%7D,%7B7,8,2%7D%7D%7D&init=%7B%7B1,1,1%7D,%7B1,1,1%7D%7D&steps=4&modelId=193&modeType=1
[7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=gigabrainGeneration4comparison.png&userId=2053745
[8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Generations2.png&userId=2053745
[9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Eventsout1.png&userId=2053745
[10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Eventsout2.png&userId=2053745
[11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Eventsout3.png&userId=2053745
[12]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Eventsout4.png&userId=2053745Tuomas Sorakivi2020-10-19T08:07:04ZCan I combine Show with GraphicsRow?
https://community.wolfram.com/groups/-/m/t/2096889
Hi guys,
the 1st step of my math model is combine model curve with experimental curve for each of the conditions I had to test. For this I am using Show[Model, Experimental], like:
ADJGrafico241 = Show[ListPlot[ADJdataModelTHEO241,
PlotLegends -> {"24h_1%_MOD"},PlotStyle -> {Blue, Dashed}], CurvaExp241]
It is perfect, showing one curve over the other.
But I have to do this 3 times, like ADJGrafico241, ADJGrafico242, ADJGrafico243. After ploting 3-Show-OverlapingCurves-Graphics, I wanna to present then one aside the other. For that, I am doing:
GraphicsRow[ADJGrafico241, ADJGrafico242, ADJGrafico243]
And I think it is not working because the output is:
![enter image description here][1]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=CapturadeTela2020-10-18%C3%A0s22.55.09.png&userId=2069783
Can I combine those? Because I really need to have a graphic with one curve overlapping the other. And to better visualize the 3 graphics I thought to put one in the side of the other.
A appreciate your help and time.silvia daou2020-10-18T20:59:11ZNarayana Cow Triangle Fractal
https://community.wolfram.com/groups/-/m/t/1286708
In 1356, Narayana posed a question in his book *Ga?ita Kaumudi*: "A cow gives birth to a calf every year. In turn, the calf gives birth to another calf when it is three years old. What is the number of progeny produced during twenty years by one cow?" This is now known as Narayana's cows sequence. The Narayana's cows sequence constant, **cow**=1.4655712318767680266567312252199391080255775684723, is the limit ratio between neighboring terms.
LinearRecurrence[{1, 0, 1}, {2, 3, 4}, 21]
NestList[Round[# Root[-1 - #1^2 + #1^3 &, 1]] &, 2, 20]
Either gives {2, 3, 4, 6, 9, 13, 19, 28, 41, 60, 88, 129, 189, 277, 406, 595, 872, 1278, 1873, 2745, 4023}. This turns out to be a good constant to use for a Rauzy fractal. The outer fractal triangle can be divided into copies of itself
r = Root[-1 - #1^2 + #1^3 &, 3]; iterations = 6;
cowed[comp_] := First /@ Split[Flatten[RootReduce[#[[1]] + (#[[2]] - #[[1]]) {0, -r^5, r^5 + 1, 1}] & /@ Partition[comp, 2, 1, 1], 1]];
poly = ReIm[Nest[cowed[#] &, #, iterations]] & /@ Table[N[RootReduce[r^({4, 1, 3, 5} + n) {1, 1, -1, 1}], 50], {n, 1,14}];
Graphics[{EdgeForm[{Black}], Gray, Disk[{0, 0}, .1], MapIndexed[{Hue[#2[[1]]/12], Polygon[#1]} &, poly]}]
![fractal Narayana Cow spiral ][1]
The ratio of areas for the triangles turns out to be **cow**. Try Area[Polygon[poly[[1]]]]/Area[Polygon[poly[[2]]]] and you'll see.
If you want to laser cut that, it's handy to get a single path.
cowpath[comp_] := First /@ Split[Flatten[RootReduce[#[[1]] + (#[[2]] - #[[1]]) {0, -r^5, r^5 + 1, 1}] & /@ Partition[comp, 2, 1], 1]];
path = ReIm[Nest[cowpath[#] &, N[Drop[Flatten[Table[r^({4, 1, 3} + n) {1, 1, -1}, {n, 1, 16}]], -1], 50], iterations]]; Graphics[{Line[path]}]
What else can be done with **cow**? With some trickier code I put together the pieces this way. Notice how order 5 spokes appear.
![Narayana cow fractal egg][2]
The opening gave an order 3 infinite spiral. Is there an order 5 infinite spiral? It turns out there is. Behold the **cow-nautilus**!
![cow-nautilus][3]
It can be made with the following code:
r=Root[-1-#1^2+#1^3&,3]; iterate=3;
cowed[comp_]:= First/@Split[Flatten[RootReduce[#[[1]]+(#[[2]]-#[[1]]){0,-r^5,r^5+1,1}]&/@Partition[comp,2,1,1],1]];
base={{r^10,r^7,-r^9,r^11},{-r^12,-r^9,r^11,-r^13},{r^8,r^5,-r^7,r^9},{-r^7,-r^4,r^6,-r^8}}+{-r^10,r^11,-r^6,r^4+r^8};
naut=RootReduce[Join[Table[base[[1]] (-r)^n,{n,0,-4,-1}],Flatten[Table[Drop[base,1](-r)^n,{n,-8,0}],1]]];
poly=ReIm[Nest[cowed[#]&,#,iterate]]&/@N[naut,50];
Graphics[{EdgeForm[{Black}],MapIndexed[{ColorData["BrightBands"][N[Norm[Mean[#1]]/2]],Polygon[#1]}&,poly]},ImageSize-> 800]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=fractalcowspiral.jpg&userId=21530
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=cowegg.jpg&userId=21530
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=cownautilus.jpg&userId=21530Ed Pegg2018-02-16T22:52:01ZUse SPI protocol with Arduino & ADC?
https://community.wolfram.com/groups/-/m/t/1029674
Hi, I'm interested in how I use SPI protocol.
In Mathematics documentation has information that might somehow use the SPI library in Arduino.
I have an Arduino Uno, and I want to connect ADC such as MAX 6675, with SPI protocol.
MAX 6675 is the ADC for temperature measurement using SPI protocol for sharing information, and there are several skeches to gather information from it.
I can not imagine how.
I am interested in whether someone has sample code to work with SPI protocol.Bohdan Romanchuk2017-03-12T23:08:59ZInput of Frequency distribution
https://community.wolfram.com/groups/-/m/t/2094513
How do we represent frequency distribution below in Mathematica?
![Frequency distribution table][1]
I can find the mean, median and mode manually. Just curious to know how can I represent the frequency distribution using Mathematica and from it determine the mean, median and mode.
The values that I determined manually using the respective formulas are mean = 35.8867, median = 33.9444, mode = 28.1364
I tried to approach it in Mathematica 12.1 by using probability distribution:
pdf[x_] := Piecewise[{{20, 19.5 <= x < 24.5},
{24, 24.5 <= x < 29.5},
{45, 29.5 <= x < 39.5},
{30, 39.5 <= x < 54.5},
{5, 54.5 <= x < 59.5},
{4, 59.5 <= x < 69.5}}, 0]
dist = ProbabilityDistribution[pdf[x], {x, 19.5, 69.5}, Method -> "Normalize"];
Mean[dist]
Median[dist]
The results that I obtained is mean = 38.9198, median = 37.7738, which are incorrect, and so is my approach.
Anyone can help?
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=dist.jpg&userId=1989747Autumn Lesoch2020-10-14T05:52:01ZCompute variance of data by function fit or other method?
https://community.wolfram.com/groups/-/m/t/2096752
&[Wolfram Notebook][1]
[1]: https://www.wolframcloud.com/obj/03599708-c586-4858-8e62-0dfe3ca46e00Richard Frost2020-10-17T18:13:25ZModify and overwrite a Dataset?
https://community.wolfram.com/groups/-/m/t/2095035
Greetings, everyone.
I hope you are doing ok during these strange times.
My question "How do you modify and overwrite a Dataset?" is motivated in the following problem:
I have imported a dataset (.csv file attached) using SemanticImport. I have added two columns to this dataset and created new corresponding datasets, using the Append function. These columns were created, as you can see, by doing some operations on data already in the dataset (The procedure is explained in this post: [https://community.wolfram.com/groups/-/m/t/313491][1]).
d2sv6 = Append[#,
"theta40" -> #["Theta_0i"] + #["m0i"]*(40 - #["A"])] & /@ d1sv6
d3sv6 = Append[#,
"theta80" -> #["Theta_0i"] + #["m0i"]*(80 - #["A"])] & /@ d2sv6
Now I need to add a large number of columns (ranging from 20 to 100) to this dataset. Unlike the examples above, the columns I am needing to include require data not already in the dataset. For instance, I need one column to be generated by each of the 50 values in the list "test80":
test80 = {-4.465980214, -4.300742326, -4.135504438, -3.97026655, \
-3.805028661, -3.639790773, -3.474552885, -3.309314997, -3.144077109, \
-2.978839221, -2.813601333, -2.648363445, -2.483125556, -2.317887668, \
-2.15264978, -1.987411892, -1.822174004, -1.656936116, -1.491698228, \
-1.32646034, -1.161222452, -0.995984563, -0.830746675, -0.665508787, \
-0.500270899, -0.335033011, -0.169795123, -0.004557235, 0.160680653,
0.325918542, 0.49115643, 0.656394318, 0.821632206, 0.986870094,
1.152107982, 1.31734587, 1.482583758, 1.647821647, 1.813059535,
1.978297423, 2.143535311, 2.308773199, 2.474011087, 2.639248975,
2.804486863, 2.969724751, 3.13496264, 3.300200528, 3.465438416,
3.630676304}
The calculation takes each value of the columns "theta40" or "theta80" (each one represents a scenario) and computes a number using each of the 50 values of the list "test80". For instance, taking just the "theta40" scenario, 50 columns should be created: one for each row-value in "theta40" in combination with each of the 50 values in the list "test80".
Of course, it becomes impractical creating an object for each added column as I did in the first part of the problem. Ideally, after all columns are created, a single new dataset should be created for each scenario. There are two main questions I have on this problem:
1. How do I append and overwrite the dataset so it includes the values from the list?
2. How do I get each new column to have a different name? Perhaps should I use an array instead of a list?
For those of you interested, this problem is relevant to the fields of psychometrics and education. The numbers to be calculated are probabilities of correct response (following what is known as a Rasch model). The values of the list "test80" can be taught as item difficulties. The data to be generated simulates performance on a test. The need to add columns to the dataset is common in education; actually the problem is trivial using a spreadsheet. The problem is that calculating huge numbers of formulas in a spreadsheet seems to be very inefficient.
[1]: https://community.wolfram.com/groups/-/m/t/313491Jorge Mahecha2020-10-14T17:53:12ZAttentionLayer is a thing in Mathematica and that's awesome
https://community.wolfram.com/groups/-/m/t/2096780
Today I was trying to understand Transformer architectures and as I was watching a [video explanation of the seminal paper "attention is all you need"][1], it occurred to me that the most difficult part to understand is the "attention layer". So I thought "wouldn't it be nice if there was an `AttentionLayer` function available in Mathematica ?", and then I checked if there happens to be one, just in case.
And sure enough, there is one.
I think the way Wolfram Research models machine learning concepts is very cool, and I just wanted to share my enthusiasm. You guys make implementing machine learning clean and elegant, keep it up !
[1]: https://www.youtube.com/watch?v=4Bdc55j80l8Lucien Grondin2020-10-17T20:18:28ZPossible Satellite Collision on 10/16/2020 UTC
https://community.wolfram.com/groups/-/m/t/2095115
[![enter image description here][1]](https://twitter.com/LeoLabs_Space/status/1316147305125490694)
&[Wolfram Notebook][2]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=7516ScreenShot2020-10-15at9.10.03AM.jpg&userId=20103
[2]: https://www.wolframcloud.com/obj/09a117f5-59da-4298-b30f-21ad1d345d32Jeff Bryant2020-10-14T20:54:06ZWolfram Cloud App on iPad Pro
https://community.wolfram.com/groups/-/m/t/2086610
Hi, I'm trying to use the Wolfram Cloud App on an iPad Pro and I'm finding it to be a very frustrating experience. I can open a Mathematica Notebook that I've saved to the cloud but I don't seem to be able to do anything but view it.
1. If I tap on an Input Cell, a Mathematica on screen keyboard pops up but I can
only append input to that existing cell, which effectively corrupts
whatever work I did in the Notebook previously.
2. If I tap below the last Output Cell I cannot find any gesture that activates the
on screen Mathematica keyboard so I am unable to add any new input to the
Notebook.
3. If I attach an Apple Magic Keyboard to the iPad Pro I can at least
type = below the last Output Cell and get the orange Wolfram Alpha
Notebook prompt but it's no where close to using Mathematica on a desktop computer and it just
feels like more effort than it's worth.
I notice that there is also the Wolfram Player on the App Store, does anyone have any experience of using it? The description of the App says "... read and dynamically interact with Wolfram Notebooks and the CDF ..." but I'm not clear if it allows you to actually write a Notebook on an iPad with the ease of a desktop.
There are times when it would be very convenient for me to be able to use Mathematica productively on an iPad but the Wolfram Cloud App is so clunky and difficult to use it doesn't seem to be the answer.Ronald Smith2020-10-01T11:23:09ZDeriving the Schwarzschild Metric
https://community.wolfram.com/groups/-/m/t/2096163
I wanted to see if covariant and contravariant coordinates could be represented in Mathematica and settled on using underscripts and overscripts, since superscripts are exponents. I'm posting the notebook as images and also attaching it. You may have to magnify the page in your browser to be able to read the code in the images.
![enter image description here][1]
![enter image description here][2]
![enter image description here][3]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=3375schwarzschild1.jpg&userId=29126
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=schwarzschild2.jpg&userId=29126
[3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=schwarzschild3.jpg&userId=29126Frank Kampas2020-10-16T20:18:34ZPosition Index of element in a Matrix
https://community.wolfram.com/groups/-/m/t/2092844
I know that one can find the index of an element in a List.
However, is there a way to get the positions of an element in a Matrix in the form of {{r1,c1},{r2,c2},...{rn,cn}} where {r1,c1} and {r2,c2} ... {rn,cn} are the rows and columns where the element is found.
I was hoping that PositionIndex applied to a matrix would do the job, but the results did not make sense to me.
Can someone tell me if there is a built-in function or a way to use PositionIndex to get the indices of where a particular number can be found.
In fact, because an element may not exactly match an entry in the matrix, I really would like a function to do the following; Return a list of all the {row,col} that are within x% (like 5%) of a number.
I would like F[mat,y,p] to return a list of coordinates (row, col) that are within p% of y.Henrick Jeanty2020-10-12T01:46:50ZPlotting electronic orbitals with Wolfram Language
https://community.wolfram.com/groups/-/m/t/131302
I am reposting this here from the [url=http://mathematica.blogoverflow.com/]Stackexchange Mathematica blog[/url] so that more people might see it. I'd be very happy to get some feedback on this plotting function. If anyone can use the function, let me know how it works out for you, and if you'd recommend any changes. If so, I can edit this post to have to most up-to-date version.
As a chemist it is often useful to plot electronic orbitals. These are used to describe the wave function of electrons in atoms or molecules. Typically, these are output from electronic structure software in the form of a cube file, first developed by Gaussian. These files contain volumetric data for a given orbital on a three-dimensional grid.
There exist many applications to visualize cube files, such as [url=http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/cubeplugin.html]VMD [/url]or [url=http://www.gaussian.com/g_tech/gv5ref/results.htm]GaussView[/url], but I wanted to take advantage of Mathematicas capability to easily combine graphics, as well as the ability to automate the process in order to efficiently create frames for a [url=http://www.pnas.org/content/suppl/2013/09/05/1308604110.DCSupplemental/sm01.mp4]movie[/url].
First off, we need a function to extract the data from the cube file. In the process, we will create the text for an XYZ file, a format also developed by Gaussian. The function [b]OutForm[/b] is used here to mimic the printf function found in other programming languages.
[mcode]OutForm[num_?NumericQ, width_Integer, ndig_Integer,
OptionsPattern[]] :=
Module[{mant, exp, val},
{mant, exp} = MantissaExponent[num];
mant = ToString[NumberForm[mant, {ndig, ndig}]];
exp = If[Sign[exp] == -1, "-", "+"] <> IntegerString[exp, 10, 2];
val = mant <> "E" <> exp;
StringJoin@PadLeft[Characters[val], width, " "]
];
ReadCube[cubeFileName_?StringQ] := Module[
{moltxt, nAtoms, lowerCorner, nx, ny, nz, xstep, ystep, zstep,
atoms, desc1, desc2, xyzText, cubeDat, xgrid, ygrid, zgrid,
dummy1, dummy2, atomicNumber, atomx, atomy, atomz, tmpString,
headerTxt,bohr2angstrom},
bohr2angstrom = 0.529177249;
moltxt = OpenRead[cubeFileName];
desc1 = Read[moltxt, String];
desc2 = Read[moltxt, String];
lowerCorner = {0, 0, 0};
{nAtoms, lowerCorner[[1]], lowerCorner[[2]], lowerCorner[[3]]} =
Read[moltxt, String] // ImportString[#, "Table"][[1]] &;
xyzText = ToString[nAtoms] <> "\n";
xyzText = xyzText <> desc1 <> desc2 <> "\n";
{nx, xstep, dummy1, dummy2} =
Read[moltxt, String] // ImportString[#, "Table"][[1]] &;
{ny, dummy1, ystep, dummy2} =
Read[moltxt, String] // ImportString[#, "Table"][[1]] &;
{nz, dummy1, dummy2, zstep} =
Read[moltxt, String] // ImportString[#, "Table"][[1]] &;
Do[
{atomicNumber, dummy1, atomx, atomy, atomz} =
Read[moltxt, String] // ImportString[#, "Table"][[1]] &;
xyzText = If[Sign[lowerCorner[[1]]] == 1,
xyzText <> ElementData[atomicNumber, "Abbreviation"] <>
OutForm[atomx, 17, 7] <> OutForm[atomy, 17, 7] <>
OutForm[atomz, 17, 7] <> "\n",
xyzText <> ElementData[atomicNumber, "Abbreviation"] <>
OutForm[bohr2angstrom atomx, 17, 7] <>
OutForm[bohr2angstrom atomy, 17, 7] <>
OutForm[bohr2angstrom atomz, 17, 7] <> "\n"];
, {nAtoms}];
cubeDat =
Partition[Partition[ReadList[moltxt, Number, nx ny nz], nz], ny];
Close[moltxt];
moltxt = OpenRead[cubeFileName];
headerTxt = Read[moltxt, Table[String, {2 + 4 + nAtoms}]];
Close[moltxt];
headerTxt = StringJoin@Riffle[headerTxt, "\n"];
xgrid =
Range[lowerCorner[[1]], lowerCorner[[1]] + xstep (nx - 1), xstep];
ygrid =
Range[lowerCorner[[2]], lowerCorner[[2]] + ystep (ny - 1), ystep];
zgrid =
Range[lowerCorner[[3]], lowerCorner[[3]] + zstep (nz - 1), zstep];
{cubeDat, xgrid, ygrid, zgrid, xyzText, headerTxt}
];[/mcode]
If you need to create a cube file, then the following function can be used:
[mcode]WriteCube[cubeFileName_?StringQ, headerTxt_?StringQ, cubeData_] :=
Module[{stream},
stream = OpenWrite[cubeFileName, FormatType -> FortranForm];
WriteString[stream, headerTxt, "\n"];
Map[WriteString[stream, ##, "\n"] & @@
Riffle[ScientificForm[#, {3, 4},
NumberFormat -> (Row[{#1, "E", If[#3 == "", "+00", #3],
"\t"}] &), NumberPadding -> {"", "0"},
NumberSigns -> {"-", " "}] & /@ #, "\n", {7, -1, 7}] &,
cubeData, {2}];
Close[stream];][/mcode]Next we need the function to plot the orbital,
[mcode]CubePlot[{cub_, xg_, yg_, zg_, xyz_}, plotopts : OptionsPattern[]] :=
Module[{xyzplot, bohr2picometer, datarange3D, pr},
bohr2picometer = 52.9177249;
datarange3D =
bohr2picometer {{xg[[1]], xg[[-1]]}, {yg[[1]],
yg[[-1]]}, {zg[[1]], zg[[-1]]}};
xyzplot = ImportString[xyz, "XYZ"];
Show[xyzplot,
ListContourPlot3D[Transpose[cub, {3, 2, 1}],
Evaluate[FilterRules[{plotopts}, Options[ListContourPlot3D]]],
Contours -> {-.02, .02}, ContourStyle -> {Blue, Red},
DataRange -> datarange3D, MeshStyle -> Gray,
Lighting -> {{"Ambient", White}}],
Evaluate[
FilterRules[{plotopts}, {ViewPoint, ViewVertical, ImageSize}]]]
]; [/mcode]Lets look at an example. First we need to read in a cube file, download this cube file and place it in your base directory: [url=https://dl.dropboxusercontent.com/s/rdsxcnqudn1s76n/cys-MO35.cube]cys-MO35cube[/url]
[mcode]{cubedata,xg,yg,zg,xyz,header}= ReadCube["cys-MO35.cube"];[/mcode]Then plot it via[mcode]CubePlot[{cubedata, xg, yg, zg, xyz}][/mcode][img=width: 300px; height: 291px;]http://mathematica.blogoverflow.com/files/2013/09/pizCq-300x291.jpg[/img]
When I want to create a movie file, I want all the images to have exactly the same [b]ViewAngle[/b], [b]ViewPoint[/b], and [b]ViewCenter[/b]. When you give these options to [b]CubePlot[/b], it feeds them directly to the [b]Show[/b] function
[mcode]vp = {ViewCenter -> {0.5, 0.5, 0.5},
ViewPoint -> {1.072, 0.665, -3.13},
ViewVertical -> {0.443, 0.2477, 1.527}};
CubePlot[{cubedata, xg, yg, zg, xyz}, vp][/mcode][img=width: 280px; height: 300px;]http://mathematica.blogoverflow.com/files/2013/09/Q1mjs-280x300.jpg[/img]
Finally, you can also give any options that normally go to [b]ListContourPlot3D[/b][mcode]CubePlot[{cubedata, xg, yg, zg, xyz}, vp,
ContourStyle -> {Texture[ExampleData[{"ColorTexture", "Vavona"}]],
Texture[ExampleData[{"ColorTexture", "Amboyna"}]]},
Contours -> {-.015, .015}][/mcode][img=width: 288px; height: 300px;]http://mathematica.blogoverflow.com/files/2013/09/fLyJ7-288x300.jpg[/img]
Many thanks to Daniel Healion for the [b]ReadCube[/b] and [b]WriteCube[/b] functions.Jason Biggs2013-09-27T18:35:45ZHow can I loop
https://community.wolfram.com/groups/-/m/t/2094640
How can I loop these short lines so that when g1=g2 I have continuing execution of x?
x=2^n-1
y=x
a=((x+y/2+x-y-1)/(x-y-1))-((x+y))/(x+y)/2
r=IntegerPart[a]
g1=Mod[r,9961]
g2={28,167,210,237,245,412,545,636,671,693,833,875,910,917,980,1014,1029,1098,1351,1358,1372,
1413,1420,1448,1526,1665,1680,1792,1834,1925,2029,2184,2240,2260,2338,2400,2401,2443,
2534,2590,2681,2771,2891,2912,2925,3016,3023,3030,3199,3255,3283,3597,3758,3759,3863,
3884,3920,3927,3976,4011,4137,4165,4200,4228,4270,4333,4438,4459,4501,4550,4570,4613,
4641,4738,4760,4788,4830,4844,4865,4871,4900,4907,4983,5004,5088,5117,5333,5334,5389,
5467,5544,5586,5859,5894,5922,5949,6061,6104,6132,6209,6230,6313,6348,6377,6467,6566,
6573,6600,6706,6720,6740,6853,6874,6887,6951,6978,6986,7083,7084,7090,7097,7202,7216,
7224,7308,7552,7608,7728,7770,7840,7854,7917,7937,7952,8028,8183,8231,8280,8323,8344,
8357,8469,8539,8568,8645,8715,8722,8742,8820,8903,8988,9029,9030,9057,9106,9135,9155,
9289,9386,9401,9485,9555,9659,9918,9960},Luis Felipe Massena Misiec2020-10-14T11:18:41ZIdentifying EEG signals with deep learning
https://community.wolfram.com/groups/-/m/t/2071595
![enter image description here][1]
&[Wolfram Notebook][2]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=sig.gif&userId=2025695
[2]: https://www.wolframcloud.com/obj/wolfram-community/Published/cortex-bci.nb
[Original]: https://www.wolframcloud.com/obj/f20171185/Published/cortex-bci.nbAnshul Chandra2020-09-06T09:55:32ZPartial differential equation to be solved
https://community.wolfram.com/groups/-/m/t/2095745
How can be solved the following PDE using NDSolve or DSolve
Derivative[1, 0][c][z, t] + Derivative[2, 0][c][z, t] - c[z, t]
== Derivative[0, 1][c][z, t]
Initial conditions:
At t =0, c(z,0)= 0, 0<=z<=1
Boundary conditions are at z=0, c=DeltaDirac(t) and at z =Infinity, c=0
(*Note: I solved the equation using Laplace Transform obtaining
c(z,t) =z/(E^((5*t^2 - 2*t*z + z^2)/(4*t))*(2*Sqrt[Pi]*Sqrt[t^3])) *)
Below is the original problem(Robert & Rowland, 1986) . Here is assumed r=1 and d=1 and mixed condition)
![enter image description here][1]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=PartialDifferentialEq.jpg&userId=430661Guillermo Sanchez2020-10-15T08:05:47Z[WSG20] New Linear Algebra Daily Study Group begins Monday, October 12
https://community.wolfram.com/groups/-/m/t/2091247
A new study group devoted to linear algebra begins Monday! A list of daily topics can be found on our [Daily Study Groups page][1]. This group will be led by Wolfram certified instructor [@Luke Titus][at0] and will meet daily, Monday to Friday, over the next three weeks. Luke will share the excellent short lesson videos created by [@Devendra Kapadia][at1] for the Wolfram U course [Introduction to Linear Algebra][2]. Study group sessions include time for exercises, discussion and Q&A. Certifications are available. Sign up: [https://wolfr.am/Q9qbTXu3][3]
[at0]: https://community.wolfram.com/web/luket
[at1]: https://community.wolfram.com/web/dkapadia
[1]: https://www.wolfram.com/wolfram-u/special-event/study-groups/
[2]: https://www.wolfram.com/wolfram-u/introduction-to-linear-algebra/
[3]: https://wolfr.am/Q9qbTXu3Jamie Peterson2020-10-08T17:22:30ZMulti-Node Multi-Core Parallel computing system on the Raspberry Pi cluster
https://community.wolfram.com/groups/-/m/t/2087381
Previous report introduced [ a parallel computing environment with ZMQ connection][1]. Wolfram language code for [Multi core computing ][2] was also reported. In this report, I'd like to introduce the **Mathematica Multi-Node Multi-Core Parallel** computing system combined prior trials and the system is composed of software key components, Object Oriented Programming, master/local ZMQ node, and the Association function.
Following sample code runs on a Master-Node of Raspberry Pi Zero and a Local-Node of Raspberry Pi 4B which has 4 cores.
Figure 1 shows the outline of this parallel computing system. Master and Local-Nodes have interconnections provided by ZMQ. A Service PC, in this case Mac, provides X11 service and is connected to the router providing DHCP services. The local net is constructed with USB-OTG between the Service PC and the multiple Raspberry Pi. In this sample, a Master-Node is prepared by a Raspberry Pi Zero, and one Local-Node is prepared by a Raspberry Pi 4B which is 4 core machine.
![enter image description here][3]
Followings are step by step sample code of the parallel computing system using [Object Oriented Programming method][4]. Where, the name of Raspberry Pi Zero is RaspberryPi7, and the name of Raspberry Pi 4B is RaspberryPi11. Each Raspberry Pi must have USB OTG. In this report, parallel Mersenne-Number calculation is a target to explain the parallel computing scheme.
**Step 1 for Master and Local**: preparing Raspberry Pi
imac : ~user$ ssh - X pi@RaspberryPi7.local
pi@raspberrypi7 : ~$ mathematica &
and
imac : ~user$ ssh - X pi@RaspberryPi11.local
pi@raspberrypi11 : ~$ mathematica &
**Step 2 on Master:** getting ip of Master-Node
HostLookup["raspberrypi7.local", All]
**Step 3 on Master:** opening the socket with the obtained ip with arbitrary port number, here, 40001
client1 = SocketOpen[{"192.168.1.10", 40001}, "ZMQ"]
**Step 4 on Local:** connecting to the Server socket, named "server"
server = SocketConnect[{"raspberrypi7.local", 40001}, "ZMQ"]
**Step 5 on Local:** setting a Socket-Listener that is the final set up for the Local-Node
listener =
SocketListen[server, (WriteString[server, ToExpression[#Data]]) &]
**Step 6 on Master:** deployment of a code to Local-Node that wakes up local cores
WriteString[client1, "LaunchKernels[];
kernelList = ParallelEvaluate[$KernelID];
{nk = Length[kernelList], kernelList}"];
ByteArrayToString[SocketReadMessage[client1]]
**Step 7 on Master:** deployment of a code of Class named "parallelClass" to Local-Node
WriteString[client1,
" parallelClass[nam_] := Module[{myID = nam, ins, ine},
nam[set[{ns_, ne_}]] := {ins, ine} = {ns, ne};
getID[] := myID;
nam[getStatus] := {ins, ine};
go[] := Select[Range[ins, ine], PrimeQ[2^# - 1] &]
]"];
ByteArrayToString[SocketReadMessage[client1]]
**Step 8 on Master:** deployment of a code of the Association is defined for the calculation parameter for each core
WriteString[client1, "object = {
Association[\"name\" -> Unique[k], \"range\" -> {9000, 9399},
\"kernel\" -> kernelList[[1]]],
Association[\"name\" -> Unique[k], \"range\" -> {9400, 9699},
\"kernel\" -> kernelList[[2]]],
Association[\"name\" -> Unique[k], \"range\" -> {9700, 9899},
\"kernel\" -> kernelList[[3]]],
Association[\"name\" -> Unique[k], \"range\" -> {9900, 10000},
\"kernel\" -> kernelList[[4]]
]}"];
ByteArrayToString[SocketReadMessage[client1]]
**Step 9 on Master:** let the Local-Node to deploy the instance for each core
WriteString[client1,
"Map[ParallelEvaluate[ parallelClass[#name], #kernel] &, object]"];
ByteArrayToString[SocketReadMessage[client1]]
**Step 10 on Master:** starting calculation on cores of Local-Node
WriteString[client1, "ts = SessionTime[];
ans = ParallelEvaluate[go[]];
{SessionTime[] - ts, ans}"];
ByteArrayToString[SocketReadMessage[client1]]
**Step 11 results appeared on Master:** Master-Node obtains the calculated result arrived on the socket
{242.348749, {{}, {9689}, {}, {9941}}}
The result shows that the consumed time and the Mersenne number found. You can confirm the results as follows.
{PrimeQ[2^9689 - 1], PrimeQ[2^9941 - 1]}
You can make above lengthy code to more easy and compact OOP code, and can expand very easily to the parallel computing system composed of more number of Local-Nodes. In the future system however, the network become not USB-OTG but powered Ether network considering the stability of power source and the network speed.
Enjoy and imagine, Ryzen multi node Wolfram environment.
[1]: https://community.wolfram.com/groups/-/m/t/2071310?p_p_auth=4c4eK4Sb
[2]: https://community.wolfram.com/groups/-/m/t/1830825
[3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=4696parallelNode.png&userId=897049
[4]: https://community.wolfram.com/groups/-/m/t/897081?p_p_auth=4c4eK4SbHirokazu Kobayashi2020-10-02T15:41:47ZParallel computing environment with ZMQ on the Raspberry Pi cluster
https://community.wolfram.com/groups/-/m/t/2071310
[Previous my parallel computing mechanism][1] worked well, however, the sequence was little-bit complex. Mathematica introduced ZMQ from ver.11 and brushed up with ver.12. With ZMQ, we can develop a parallel computer system very easily. The basic code and first result are shown here, using Raspberry Pi cluster composed of, one Raspberry Pi 4B for the server, and two Raspberry Pi Zero. Three boards were build up to a computing cluster with Powered USB bus adapter connected to PC, in this case, Mac.
**Preparation for the Raspberry Pi system**
Each Raspberry Pi should be prepared for running RNDIS/Ethernet Gadget (with PC using a USB cable, Raspberry Pi can handle through the PC). Then we can control each Raspberry Pi through a X11 window of Mac Xquartz (should be started in advance). Also, you can use VNC viewer.
First step is starting Mathematica on each Raspberry Pi, as following steps.
a. with PC terminal, login to Raspberry Pi as (supposing Raspberry Pi name is "RspberryPi6, ..Pi3, and ...Pi12), where user name is "pi."
$ ssh -X pi@RaspberryPi6.local
b. with PC terminal, let's start Raspberry Pi Mathematica, and wait the opening of Mathematica X-window.
pi@raspberrypi6:~ $ mathematica &
c. repeat this process for raspberrypi3(another Raspberry Pi Zero) and for raspberrypi12(Raspberry Pi 4B, in my case).
**Code for the server (raspberrypi12)**
in my local net, IP of raspberrypi12 is 192.168.1.8, and the definition port number, here I chosen, 40001, and 40002. Then following code will open the Socket. Some warning will come up, but the socket will work.
client1 = SocketOpen[{"192.168.1.8", 40001}, "ZMQ"];
client2 = SocketOpen[{"192.168.1.8", 40002}, "ZMQ"];
Then, you should write a code for each client. The client code, on the raspberrypi3, is,
server = SocketConnect[{"raspberrypi12.local", 40002}, "ZMQ"];
listener =
SocketListen[server, (WriteString[server, ToExpression[#Data]]) &]
Next, you should write a code for the another client, for example, raspberrypi6 is,
server = SocketConnect[{"raspberrypi12.local", 40002}, "ZMQ"];
listener = SocketListen[server, (WriteString[server, ToExpression[#Data]]) &]
All the code required for the clients are only 2-lines.
You will return to the **server**.
Next code is purposed to deploy the clients (client1 and client2) sample calculation code. When you execute the code, you will see **Null** as return.
WriteString[client1, "f[x_]:=(Pause[4];x^2-1)"];
ByteArrayToString[SocketReadMessage[client1]]
WriteString[client2, "f[x_]:=(Pause[4];x^2+1)"];
ByteArrayToString[SocketReadMessage[client2]]
A cord part "Pause[4]" is a dummy code to demonstrate the parallel computation. At this point, you can see a deployed and executable code from the client (through X11 window).
**C. Evaluation of the parallel computing system on the Raspberry Pi cluster**
Sample codes on the server are,
Timing[{WriteString[client1, "f[200]"],
WriteString[client2, "f[200]"]};
{ByteArrayToString[SocketReadMessage[client1]],
ByteArrayToString[SocketReadMessage[client2]]}]
result is,
{5.55364, {"39999", "40001"}}
Comparing single cpu calculation, you will see as,
Timing[WriteString[client1, "f[200]"];
ByteArrayToString[SocketReadMessage[client1]]]
result is,
{5.81473, "39999"}
Certainly, the parallel computation system is now working well.
This preliminary parallel computer environment has shown some advantages ,
1. Server code is very simple
2. client code has no necessity of modification for any applications
3. local net is fulfilling the requirements for parallel computer system
4. [parallel node with multi-core][2] can be easily developed
5. ZMQ will run not only usb network but (powerd, and/or fast) ether net
Enjoy!
[1]: https://community.wolfram.com/groups/-/m/t/1057588?p_p_auth=gw4gJRn7
[2]: https://community.wolfram.com/groups/-/m/t/1830825?p_p_auth=gw4gJRn7Hirokazu Kobayashi2020-09-05T10:28:18ZSeries expansion of a term includes vectors?
https://community.wolfram.com/groups/-/m/t/2094452
![enter image description here][1]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=10292Image1.png&userId=2094437MAHMUDUL HASAN2020-10-14T04:45:19ZFunction for principal component analysis (PCA)?
https://community.wolfram.com/groups/-/m/t/2094481
I downloaded the Boston housing price data collection from the Internet for practice.
Related blogs discuss principal component analysis (PCA).
But I did not search for relevant examples, commands, or functions on the Wolfram website.
Are there any readily commands or functions for PCA in Mathematica?
Remove["Global`*"]
{key, data} = {First@#, 0.0 + ToExpression@Rest@#} &@
Import["https://raw.githubusercontent.com/selva86/datasets/master/\
BostonHousing.csv", {"CSV", "RawData"}];
{test, train} =
TakeDrop[#, 100] &@((#[[1 ;; -2]] -> #[[-1]]) & /@ data);
p = Predict[train];
m = PredictorMeasurements[p1, test];
m["Properties"]Tsai Ming-Chou2020-10-14T07:30:09ZKernel crashes while creating plot in manipulate?
https://community.wolfram.com/groups/-/m/t/2094499
I wanted to make a manipulate where an ellips is moving if I move a point (p1 and p2). I calculate in a function the ellips and some points of it and return points in a list. The input values of the function are
the variables of the manipulate. I tested the function before, everything seems OK.
If I use the list of points (I hope they are dynamical) in the manipulate (the last in the notebook) the kernel crashes. I have a error message: An unknown box name (ToBoxes) was sent as the BoxForm for the expression. Check the format rules for the expression.
I added a notebook with comments. I hope someone will have the time to look. I tried already a couple of days.
Many thanks.
Wiel
&[Wolfram Notebook][1]
[1]: https://www.wolframcloud.com/obj/e6df71e1-3f56-452c-bc4f-e3af4ef5f595Wiel Aerts2020-10-14T09:58:03ZConnecting to a remote kernel with a ssh key ?
https://community.wolfram.com/groups/-/m/t/2094031
According to [this documentation page][1], it's possible to connect to a Wolfram kernel from a remote machine via SSH. I installed a kernel on a remote machine but I fail to use it as a kernel. With my first try Mathematica wasn't even asking me any password (this may not be Mathematica's fault as I can't connect from any of my machine without a SSH key anyway).
So I thought I needed a ssh key so I tried setting [$SSHAuthentication][2] to access that machine from Mathematica, and I tested it with [RemoteConnect][3] and it works surprisingly well, but when I try to actually use the kernel, Mathematica gives me the error :
SSH encountered a networking error while launching kernel 'testRemoteKernel'. Error code = 300.
and it still doesn't even ask me a password.
So it's not like I can's use SSH (since RemoteConnect does work), I must be missing something else.
[1]: https://reference.wolfram.com/language/howto/ConnectToARemoteKernel.html
[2]: https://reference.wolfram.com/language/ref/$SSHAuthentication.html
[3]: https://reference.wolfram.com/language/ref/RemoteConnect.htmlLucien Grondin2020-10-13T20:41:37ZUnwanted frame label while using PlotLayout option
https://community.wolfram.com/groups/-/m/t/2094145
I've got unexpected behaviour of the frame labels while plotting several plots in a row using the `PlotLayout` option. Except of two nice labels placed where they should be a third one is generated in the center of the whole image.
Consider the following code:
x = Subdivide[- Pi, Pi, 100];
sin = Sin[x];
cos = Cos[x];
ListLinePlot[{Transpose[{x, sin}], Transpose[{x, cos}]},
PlotLayout -> "Row",
FrameLabel -> {"x", "F[x]"}]
I would like to get something like this:![enter image description here][1]
But instead the following picture is generated:![enter image description here][2]
The difference is pretty minimal: an additional frame label occures in the bottom-center of the latter image. So, the question is: how to get rid off this extra label? And is it conventional behaviour or a bug?
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=whatIneed.jpg&userId=1761135
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=whatIget.jpg&userId=1761135Nikolay Shilov2020-10-14T10:06:07ZOptions AspectRatio and ImageSize within DateListPlot or DateListLogPlot
https://community.wolfram.com/groups/-/m/t/2051827
Hello Community
Why do the Options AspectRatio and ImageSize not work when defined in SetOptions[DateListPlot ... ] ? They work well when defined within DateListPlot or DateListLogPlot.
Options[DateListPlot] list them as an option.
I always get the default plot ratio and size.
With kind regards
PeterPeter Anliker2020-08-05T08:38:00Z