Skip to main content

Posts

Showing posts from December, 2014

bugs - AndersonDarlingTest and DistributionFitTest Leaking Memory

I believe AndersonDarlingTest and probably all other tests are keeping a copy of data somewhere and not freeing it: Quit[]; (*Must be run in different cell*) $HistoryLength = 0; memdata = {{MemoryInUse[], MaxMemoryUsed[]}}~Join~Table[ data = RandomVariate[ MultinormalDistribution[{0, 0}, {{1, 1/2}, {1/2, 2}}], 1000000]; dist = MultinormalDistribution[{ux, uy}, {{a, c}, {c, b}}]; AndersonDarlingTest[data, dist, {"FittedDistributionParameters", "PValue"}]; Clear@data; Clear@dist; ClearSystemCache[]; {MemoryInUse[], MaxMemoryUsed[]} , {10}]/1024.^2; ListPlot[Transpose@memdata, Joined -> True, PlotLegends -> Placed[{"MemoryInUse", "MaxMemoryUsed"}, Top], AxesLabel -> {"Iteration", "Memory (MB)"}] Questions: Am I missing something obvious or is this a bug? Just want to make sure before I report it... Is there a work around? I've been spelunking with the excelle...

keyboard - On a Mac OS X, Ctrl-Backspace generates ascii code 8 (backspace), which is almost invisible but very annoying

When I press Ctrl-Backspace, Mathematica inserts what looks either like a tiny white space or sometimes is invisible. Actually, though, it is an ascii character code 8, also enterable in Mathematica as \.08 . The presence of this character completely messes up code and is very difficult to diagnose (for example, \.08a is different from a , but they look identical). I can't imagine the purpose of this behavior but I desperately want to get rid of it. Ideally, Ctrl-Backspace would delete the previous word, like in a sensible application. I would be completely content, though, with disabling all behavior when I press Ctrl-Backspace. I have tried looking in KeyEventTranslations.tr but I didn't find the origin of this behavior. Note that I am using Mac OS X 10.9.3 and Mathematica 9.0.1.0 on a MacBook 2012.

plotting - Plot counting function semi primes

I am trying to generate a plottable semi-prime counting function. Have tried: DiscretePlot[Gather[{a = PrimeOmega[Range[100]]; b = PrimeNu[Range[100]]; Count[Transpose[{a, b}], {2, 2}]} + {a = PrimeOmega[Range[100]]; b = PrimeNu[Range[100]]; Count[Transpose[{a, b}], {2, 1}]}],{x, 0, 15}, Filling -> Bottom]] but really have no clue as to where to go from here! Answer a = PrimeOmega[Range[100]]; b = PrimeNu[Range[100]]; ListPlot[{Accumulate[Flatten[Inner[If[#1 === #2 === 2, 1, 0] &, a, b, List]] + Inner[If[#1 === #2 + 1 === 2, 1, 0] &, a, b, List]], Table[PrimePi[x], {x, 100}]}] Makes quite a nice comparison

front end - Is there a way to control V10's undo length?

This may be a duplicate (if so I will remove this), but I was having trouble finding the relevant bit of documentation to fix it. I noticed that my FrontEnd memory use was growing out of control when I was repeatedly using Image on data, even if the image was being deleted shortly after being generated. As a minimal example: Image[RandomReal[{0, 1}, {2000, 2000, 3}]] Every time this line is executed, FrontEnd RAM use (as measured by both MemoryInUse[$FrontEnd] and an external profiler) jumps by 120MB, even though the previous image is deleted every time the line is re-executed. I assume this means the images are being invisibly stored somewhere inside the frontend, but I have been having trouble finding out exactly where, and as a result I keep having to quit and restart the application because memory use keeps ballooning out of control. I glanced through $FrontEnd // Options but didn't see anything obviously related. A similar problem regarding Rasterize was discussed here ;...

fitting - NonlinearModelFit: fit a vector-valued function to a data vector

I have a vector of data points: data = 10 Sin[#/10] + RandomVariate@NormalDistribution[] & /@ Range[200]; And I have model that provides the complete data vector as value matrix = Table[i (Sin[j/10]), {i, 20}, {j, 200}]; weights[a_] := Table[PDF[NormalDistribution[a, 1], i], {i, Range@20}]; model[a_] := weights[a].matrix; model[10] is a good approximation of data. They way I currently determine the fit parameters is by using FindMinimum and explicitly minimize the fit penalty: FindMinimum[ Total[(data - model[a])^2], {{a, 10}} ] This works nice. But the evaluation of fit statistics like error volumes is very tedious because the underlying matrix and the model function is rather complex. When fitting with NonlinearModelFit instead, a lot of those statistics are readily available. But I have struggled to adapt it accordingly: Something like NonlinearModelFit[ data, model[a], {{a, 1}}, var ] Unfortunately, there are problems. Can it be adapted? I dont actually need any v...

plotting - ListPlot InterpolationOrder->0 datapoint centered

it is possible to get a histogram style in ListPlot using InterpolationOrder->0 testdata = {{1, 3}, {3, 4}, {4, 3}, {5, 8}, {7, 6}, {9, 4}}; ListPlot[testdata, Joined -> True, InterpolationOrder -> 0, Epilog -> {PointSize[Large], Point[testdata]}] Note that the data points are sitting at the corner of the histograms at the left end of the horizontal lines. My question is: How could I plot the same data set with the data points being centered on the horizontal line segments? For equidistant data points this is of course a simple shift. But how to do this for irregularly gridded data? Edit 1: To clarify: Of course this is possibly not very meaningfull in irregularly spaced cases, and centered is the wrong term, however, in the example case the data point connection I was looking for could look like the following: Answer This uses Nearest to build a NearestFunction ( nf ) for your testdata . This is like InterpolationOrder -> 0 except that it is centered because it do...

graphics - How can I pack circles of different sizes into a spiral?

Given a list of circles of different areas, I need to arrange them tangentially in order of increasing area and spiraling outward. An example of the type of packing I'm attempting is shown by the orange circles in the figure below: Is there a concise way to calculate the centers of the circles? Answer Here's my version. I don't know how fast/slow it is compared to the other solutions, but at least is shortish. spiral[rlist_ /; Length[rlist] >= 2] := Module[{findCentre}, findCentre[zlist_] := Module[{coslst, theta, ind, k}, k = Length[zlist] + 1; coslst = Table[ With[{dist = N@Norm[zlist[[-1]] - zlist[[l]]]}, ((rlist[[k - 1]] + rlist[[k]])^2 - (rlist[[k]] + rlist[[l]])^2 + dist^2)/dist], {l, k - 2}]/2/(rlist[[k - 1]] + rlist[[k]]) ; ind = Flatten[Position[coslst, a_?NumericQ /; Abs[a] theta = Min[Mod[#, 2 Pi, ArcTan @@ (zlist[[-2]] - zlist[[-1]])] &@(-ArcCos[ coslst[[ind]]] + (ArcTan @@ (# - zlist[[k - 1]])...

differential equations - FEM-ception: Using output of NDSolve FEM as input in another FEM problem

After having solved a Stokes flow problem in Mathematica on a subdomain RegionCapillary , I would like to solve an advection-diffusion problem on a larger domain RegionShell which contains the previous domain. This means taking the InterpolatingFunction returned by NDSolve FEM for the Stokes problem and setting it to zero everywhere on RegionShell , so that the Stokes velocity field can be used in the advection term of the transport problem on RegionShell . The solution, produced by Comsol, shows concentration boundary layers: The left picture shows a solution of the velocity field $\boldsymbol{u}$ of the Stokes problem $\nabla\cdot\boldsymbol{u}=0, \nabla p=\mu\nabla^{2}\boldsymbol{u}$ solved on the domain RegionCapillary . The right pictures shows a solution of concentration field $c$ from the advection-diffusion problem $Pe\boldsymbol{u}\cdot\nabla c=\nabla^{2}c$ solved on RegionShell . Let's see if I can retrieve the Comsol solution in Mathematica. RegionCapillary = ...

packages - Begin["`Private`"] vs Module

So, if you have a package formatted like so: BeginPackage["MyPackage`"]; Begin["`Private`"]; someFunction:=( x=3; y=4; out=x + y; ) End[]; Begin["`Private`"]; anotherFunction:=( x=5; z=7; out= x + z; ) End[]; EndPackage[]; Is x treated locally? Like if you call the function anotherFunction , does Mathematica know the difference between the xs since they both have the context MyPackage`Private or is each instance of Private independent of the other? If so, then why use Module to make variables local rather than the Private context. Answer Reading How symbol lookup actually works will teach you that your code produces such definitions: MyPackage`Private`someFunction:=( MyPackage`Private`x = 3 ; MyPackage`Private`y = 4 ; MyPackage`Private`out = MyPackage`Private`x + MyPackage`Private`y ) MyPackage`Private`x in both functions is the same and there is no mechanism which will prevent those values from interfering. Put e.g P...

FindInstance (and Solve, ...) abysmally slow on a fully determined system of linear equations and inequalities: why?

I took a quick look for FindInstance and Solve -related questions but came up empty for the aspect that I am curious about. So here is my newbie question: FindInstance[{ s==9,r==8,d==7,n==6,e==5,y==2,m==1,o==0 },{s,e,n,d,m,o,r,y},Integers] runs as quickly as one would expect. But FindInstance[{ s!=e!=n!=d!=m!=o!=r!=y, s==9,r==8,d==7,n==6,e==5,y==2,m==1,o==0 },{s,e,n,d,m,o,r,y},Integers] takes ages -- long enough that I ran out of patience before MMA was done. And now I am curious: Why would Mathematica suddenly display less maths ability than a third-grader? bill_s suggested something much faster, but it is not equivalent to the original problem. The original inequality required all variable values to be different from all other variable values, such that each value can only be used for one variable. The FindInstance statement in Bill's post only compares x[i] to the i th value, but not to the other n-1 values. In other news, FindInstance[{ (*s!=e,s!=n,s!=d,s!=m,s!=o,s!=...

dynamic - Trouble using If[] within TabView Manipulate control

If I place an If in the "body" of a Manipulate as in: Manipulate[tick; Dynamic@If [ s1 == 1, {"m1 ", Manipulator[Dynamic[m1, (m1 = #; tick = Not[tick]) &], {1, 4}], " ", Dynamic[m1]}, {"m2 ", Manipulator[Dynamic[m2, (m2 = #; tick = Not[tick]) &], {0, 1}], " ", Dynamic[m2]} ] , TabView[{ "1" -> Grid[tabNumber = t1;(*Dynamic@*){ }], "2" -> Grid[tabNumber = t2; { {"s1 ", SetterBar[Dynamic[s1, (s1 = #; tick = Not[tick]) &], Range[2]], " ", Dynamic[s1]} }] }, Dynamic@tabNumber] , {{tick, False}, None} , {{tabNumber, 1}, None} , {{t1, 1}, None} , {{t2, 2}, None} , {{m1, 1}, None} , {{m2, 1}, None} , {{s1, 1}, None} , TrackedSymbols :> {tick}, ControlPlacement -> Left ] Then the selection of the s1 SetterBar control switches the m1/m2 control in the Manipulate display without any trouble: I'd like to have this condition within the TabView ...

Object detection in a low contrast image

I have a small dark object in the upper left corner of an image . How can I separate it from the noisy rest and determine its IntensityCentroid ? The problem is that the objects intensity is not significantly lower than the intensity in the lower part of the image: ListPlot3D[ImageData[image] // N] UPDATE : Following the question Finding objects in images with inhomogeneous background I tried: imageN = ColorNegate[image]; background = ImageConvolve[imageN, GaussianMatrix[7]]; subImage = ImageSubtract[imageN, background]; t = FindThreshold[subImage, Method -> "Entropy"]; binImg = DeleteSmallComponents[Binarize[subImage, t], 5]; pts = ComponentMeasurements[ImageMultiply[image, binImg], "IntensityCentroid"] Show[image, Graphics[{Red, Point[pts[[All, 2]]]}]] which gives: {1 -> {77.2279, 397.997}} Unfortunately the other solutions for the mentioned question cannot detect the object here. As Rahul mentioned also background = MedianFilter[imagen, 10] can be used ...

plotting - Hightlight all the self-intersections of a Lissajous figure

This graph–also known as a Lissajous figure–contains so many self-intersections.How can I highlight them? ParametricPlot[{Sin[100 t], Sin[99 t]}, {t, 0, 2 π}, PlotRange -> All] Answer Manipulate[ ParametricPlot[({Sin[n t1], Sin[(n - 1) t1]}), {t1, 0, 2 Pi}, Epilog -> {Red, PointSize[Large], Table[If[OddQ[i + j], Point[{Cos[Pi i/(2 (n - 1))], Cos[Pi j/(2 (n))]}]], {i, 2 n - 3}, {j, 2 n - 1}]}], {{n, 5}, 2, 20, 1}] General Case I We can generalize to the Lissajous curve specified by the two non-negative integers $a$ and $b$: $$ x = \sin at \\ y = \sin bt \\ t \in [0,2\pi) $$ Without loss of generality, I will assume $b We can start by making a table of small cases: Column[Row /@ Table[ParametricPlot[({Sin[a t], Sin[b t]}), {t, 0, 2 Pi}, Epilog -> {}, PlotLabel -> {a, b}, Axes -> False, ImageSize -> Tiny], {a, 10}, {b, Select[Range[a - 1], CoprimeQ[#, a] &]}], Alignment -> Center] When both $a$ and $b$ are odd, we get a dege...

initialization - Why can't I import a file in the init.m file?

I would like to have some data read in every time the kernel starts, but it doesn't seem to work. Say I have a CSV file I want to have read in, for example I use: Export["/home/jason/temp.csv", Table[{n, 2 n, 3 n}, {n, 5}]]; Quit[]; Then I open up the init.m file in a text editor and add the line temp123=Import["/home/jason/temp.csv"]; I save the file, then go back to a notebook and reopen the kernel and ask for the definition of temp123 , it comes back as Null ?temp123 (* Global`temp123 temp123=Null *) What is the best way to do this? I've tried putting the call to Import the CSV file in another file which is called by init.m , but the result is the same. Thanks Answer I think that the reason is that -- depending on the format -- Import does either use external programs, java libraries via JLink or the frontend for imports of most "nontrivial" formats. Only some -- mainly simple ascii or plain binary -- formats and of course mathematicas o...

plotting - How to find and count the points that are elements of ${(x,y)inmathbb{Z}^2:x^2+y^2le16 wedge |y|gt x}$?

I am given the following set: $\qquad \{(x,y)\in\mathbb{R}^2:x^2+y^2\le16 \wedge |y|\gt x\}$ I want find and count the number of points in this set that have integer coordinates. I drew this to help me visualize the problem. ClearAll["Global`*"]; Plot[{y /. Solve[x^2 + y^2 == 16, y], x, -x}, {x, -5, 5}, PlotStyle -> {Solid, Dashed, Dashed}, AspectRatio -> 1, PlotRange -> {{-5, 5}, {-5, 5}}, PlotTheme -> "Detailed", GridLines -> {{-4, -3, -2, -1, 0, 1, 2, 3, 4}, {-4, -3, -2, -1, 0, 1, 2, 3, 4}}] I want to mark all of those points which are inside the set red as well as count them. What should I do? Answer Just solve it: sol = Solve[x^2 + y^2 x, {x, y}, Integers]; Get how many: Length@sol Make the points (set point size or use Disk if you want bigger): gr = Graphics[{Red, Point[{x, y}] /. sol}]; Then show them together: Show[{Plot[{y /. Solve[x^2 + y^2 == 16, y], x, -x}, {x, -5, 5}, PlotStyle -> {Solid, Dashed, Dashed}, AspectRatio -...

A series in powers of $(a-z)$ instead of $(z-a)$

Sometimes it is more convenient to find a series expansion (e.g., Taylor, Laurent, Puiseux, ...) in powers of $(a-z)$ than in powers of $(z-a)$. For instance, the command Series[(1 + Sqrt[1 - 4*z^2])/(4*z) - z, {z, 1/2, 3}] gives $$i\sqrt{z - \frac{1}{2}} - 2\left(z - \frac{1}{2}\right) - \frac{3}{2}i\left(z - \frac{1}{2}\right)^{3/2} + \frac{23}{8}\left(z - \frac{1}{2}\right)^{5/2} - 4\left(z - \frac{1}{2}\right)^3 + O\left(z - \frac{1}{2}\right)^{7/2}.$$ The series expansion in powers of $\left(\frac{1}{2} - z\right)$ is nicer in this case, as the coefficient at the leading term becomes real. So I would like to ask what is the preferable way to obtain an expansion in terms of $\left(a - z\right)$ instead of $\left(z - a\right)$. Thank you in advance.

computational geometry - How to create a neighboring list for a given triangulation and find the triangle and construct the tile?

I am new to Mathematica and I am currently in need of some help with creating a neighboring list of triangles for a given triangulation and finding the path to the triangle containing the random point and constructing a tile. So basically, this problem involves the Delaunay Triangulation. I can generate the triangles using DelaunayMesh but I can't find the neighboring triangles, the path to the triangle containing the random point, and construct the tile. This is what I have so far. (* Number of data points *) numpts = 5; (* Test data set *) pts = {{0, 0}, {1, 0}, {0, 1}, {1, 1}, {0.3, 0.4}}; dmesh = DelaunayMesh[pts]; (* Extract the triangle list from the Delaunay triangulation *) tris = MeshCells[dmesh, 2]; numtris = Length[tris]; (* This demonstrates how to access the pts from the tris list *) Print["Number of triangles numtris = ", numtris]; Do[ Print["Tri ", i, " v1=", pts[[tris[[i, 1, 1]]]], " v2=", pts[[tris[[i, 1, 2]]]], ...

physics - Dynamic Euler–Bernoulli beam equation

I am trying to solve for the vibration of a Euler–Bernoulli beam . The equation is $\frac{\partial ^2u(t,x)}{\partial t^2}+\frac{\partial ^4u(t,x)}{\partial x^4}=0$ For the boundary conditions I would like the displacement to be zero at the ends and with zero second derivative. This corresponds to pinned-pinned conditions. For time I will start with a displacement and no velocity. In the future I would like to solve for a beam that is not uniform in thickness along the x-axis and for general initial conditions. There is a similar problem in the NDEigensystem documentation here but this is for the standard wave equation which is only second order in space. However, I follow that example. First I define an initial displacement and try to solve the pde. ClearAll[f]; f[x_] := x (1 - x) tu = NDSolveValue[{ D[u[t, x], {t, 2}] + D[u[t, x], {x, 4}] == 0, u[0, x] == f[x], Derivative[1, 0][u][0, x] == 0, DirichletCondition[u[t, x] == 0, True], DirichletCondition[D[u[t, x], ...

Is there a fast method of generating a Standard Deviation image from a frame stack?

Imagine I have a stack of image frames, $(f_1, ..., f_N) \in F$, where each $f_i$ has the same set of $(x,y)$ dimensions. Using these frames, I'd like to create an image where each pixel in the image consists of the standard deviation of the values at the corresponding pixel position in each of the $f_i$. Unfortunately, the following procedure is painfully slow (when applied to a $256 \times 256$ pixel image): SDImage = ImageData@FrameStack[[1]]; For[a = 1, a For[b = 1, b SDImage[[a, b]] = StandardDeviation[Table[ImageData[FrameStack[[k]]][[a, b]], {k, 1, Length[FrameStack]}]]; Print[SDImage[[a, b]]]; ]; ]; SDImage = Image[SDImage] Is there a faster method of doing this, or perhaps a built in tool (like in ImageJ)? Answer Assuming you have loaded a stack of images and stored in a variable called imageStack you can do the following to compute the standard deviation image over the entire stack: imageStack = Import["ExampleData/CTengine.tiff"]; xySt...

front end - Convert a Notebook directly to a package with boiler plate

I want to be able to turn a bunch of notebooks I have into packages so I can more easily share them with others, without having to go through the boiler-plate of choosing which cells to export / doing a "Save As..." , re-indenting all of my input cells, writing usage messages, etc. All my code is in "Input" and "Code" cells. How could I do this?

Some time difficulty in a Manipulate program inside a DynamicModule

This work began at Set PlotLabel length . slopeExplorer[fn_, {x_, xmin_, xmax_}, {y_, ymin_, ymax_}] := DynamicModule[{f, pta, ptb}, f[t_] = fn /. x -> t; Manipulate[ pta = {a, f[a]}; ptb = {a, f'[a]}; Show[ Plot[{Tooltip[f[x]], Tooltip[f[a] + f'[a] (x - a)]}, {x, xmin, xmax}, PlotStyle -> {Directive[Blue], Directive[Orange]}, PlotRange -> {ymin, ymax}, PlotLabel -> Pane["Slope of tangent line = " ToString[PaddedForm[N[f'[a]], {6, 2}]] "\n", 200]], Plot[Tooltip[f'[x]], {x, xmin - 0.01, a}, PlotRange -> All, PlotStyle -> Directive[Red, Dashed]], Graphics[{ Gray, Line[{pta, ptb}], Red, PointSize[Medium], Tooltip[Point[pta], pta], Blue, Tooltip[Point[ptb], ptb] }] ], {{a, xmin, "x"}, xmin, xmax, Appearance -> "Labeled"} ] ] The following example seems to work perfectly. slopeExplorer[2 x^3 - 3 x^2 - 36 x, {x,...

plotting - How can I draw a 3D cross-section of a 3-torus embedded in 4D Euclidean space?

I have a $3$-torus ($\mathbf S^1\times\mathbf S^1\times \mathbf S^1$) embedded in 4D Euclidean space. How can I draw the cross-section of this $3$-torus cut by a 3D Euclidean space in an arbitrary direction? The equations are: $$\begin{align*} x &= (r + (t + d\cos\,a)\cos\,b)\cos\,c\\ y &= (r + (t + d\cos\,a)\cos\,b)\sin\,c\\ z &= (t + d\cos\,a)\sin\,b\\ w &= d\sin\,a \end{align*}$$ where $x,y,z,w$ are the orthogonal coordinates in 4D space, $r,t,d$ are the radii of three circles, and $a,b,c$ denote the angles of the point with respect to the three circles. Answer Take $r=1, t=5, d=10$ for example: r = 1; t = 5; d = 10; The parametric equation for the 3-torus is given by: torus3 = {(r + (t + d Cos[a]) Cos[b]) Cos[c], (r + (t + d Cos[a]) Cos[b]) Sin[c], (t + d Cos[a]) Sin[b], d Sin[a]}; Suppose the plane is determined by its normal $\mathbf n$ and a point $\mathbf o$ on it: \[DoubleStruckN] = Normalize[RandomReal[{0, 1}, 4]] \[DoubleStruckO] = Rando...

Does pass-by-value affect the performance of function calls?

I only have a little coding experience in C, and I remember I was told that pass by reference is more efficient than pass by value since the parameters don't need to be copied. Since there is no pass by reference in Mathematica , I'm wondering if that affects the performance of function calls, especially when dealing with large data? Answer In Mathematica, this does not affect performance because copying does not take place most of the time. To put it simply, Mathematica implements copy-on-demand: it creates a copy of the data structure only if it is modified. Please see this answer for a more detailed explanation: Does passing a variable with a large amount of data cost a lot of memory and time in Mathematica?

variable definitions - Context of localised (dynamic) symbols

When you localise a symbol with Module , the created unique symbol is usually in the current context . There seems to be an exception to this which has further consequences. Let us assume we define a symbol in a package. We can mimic this by defining a symbol in some context and append this context to the $ContextPath : AppendTo[$ContextPath, "MyContext`"] MyContext`x = "Package Variable"; If you look at ??x you'll see that we really have only one x in MyContext` . What is surprising at first glance is the following: Module[{x}, Information[x] ] While you might be tempted to say "who cares?", this has consequences! Without evaluating the following, try to guess the output: Module[{x = "Local Variable"}, {x, MyContext`x} ] The output is {"Local Variable", "Local Variable"} There are further consequences: The standard context of DynamicModule variables is $CellContext . This means, even when you have defined some variab...

export - High memory use while exporting a BMP

Something mysterious is going on when exporting images. I'm using Mathematica 9.0.1 on Windows 7 (64 bit), and find that the memory use is excessive when exporting to a bmp. But it doesn't happen with other image formats. For example, running the following (with different values for k ): k = 1; extensions = {"png", "tif", "jpg", "bmp"}; SeedRandom[42]; image = Image@RandomReal[{0, 1}, {1500, 1500, 3}]; base = MaxMemoryUsed[]; Export["C:\\mem." extensions[[k]], image]; {extensions[[k]], (MaxMemoryUsed[] - base)/1024.^2} Quit[] gives {"png", 79.987} {"tif", 28.617} {"jpg", 60.453} {"bmp", 927.602} file sizes ( added by s0rce ): png: 12.8 MB tif: 12.8 MB jpg: 1.29 MB bmp: 6.43 MB Why does exporting a bmp require over 10 times the memory of other image formats? And what can I do about it? EDIT: Here's the results of some more testing (code at the end). format texture type memory...

neural networks - Can you train ImageClassify model with multiple GPUs correctly?

After some testing, I still cann't train with two GPU in Windows 10. But I can train with Mathematica 11.3 in Ubuntu 16.04 with two graphics card GTX 1080 The problem is, If I use two card to train, the model is not so trainable as we can see the loss curve in the following pictures. Not the reason of BatchSize's setting, I've tested the BatchSize Value From 50 to 250 in the case of TargetDevice->{"GPU",All} . Is this a bug? You may try the MNIST example NetTrain[NetModel["LeNet"], trainingData, ValidationSet -> testData, TargetDevice->{"GPU",All}]

evaluation - How to see which arguments are passed into a function

It is often that one wonders which arguments are evaluated before being passed into a function. I would like to know if it is possible to see which argumets are being passed into a function without recoding the function, that is, outside of the function. I know that one could try with the Trace command, but it always puzzles me whether the output one really sees reflects what is being sent into the function prior to its evaluation. I suppose, that the key issue is being able to draw a clear line, and say, "yes, these expressions are being fed into the function, and, aha, these evaluations are done in the function". Is there a generic way of doing this without recoding the function (that is, one could put a bunch of print statements in the definition of the function)? For example, I might want to know which arguments are actually passed to a built-in Mathematica function (which one cannot recode) and might need to know what is done with these arguments within the function code...

front end - How do I remove the top bar and bottom bar from the Students Mathematica window?

Any idea how to remove the top bar saying "Wolfram Mathematica .... Demonstrations MathWorld Studenforum Help" from the Mathematica main window (see screenshot). It has no use to me and it steals real estate from my laptop sreen. Also : How do I remove the bottom bar with the zoom button? Appreciate any help! keywords : student's edition dockedcells toolbar

bugs - The shortcut for Subsuperscript doesn't work?

The document for Subsuperscript says that: To enter a subsuperscript in a notebook, use either Ctrl + _ to begin a regular subscript or Ctrl + ^ to begin a regular superscript. After typing the first script, use Ctrl + % to move to the opposite script position. Ctrl + Space moves out of the subscript or superscript position. This just create a expresion that looks like a symbol with subsuperscript! Specifically, I typed Ctrl + - / Ctrl + 6 and a regular subscript / superscript appeared, Ctrl + 5 and the opposite script appeared, and after I moved the cursor out of the symbol by pressing → and checked its InputForm , what I saw is not something like Subsuperscript[a, x, y] but Subscript[a, x]^y Snapshot: What's wrong with it, I misunderstood the document? I use Mathematica 8.0.4 and Windows Vista Home Basic 32bit . Answer It appears that when you use Control - % to create something that looks like $x_a^b$, the underlying box representation will be a SubsuperscriptBox ...

splines - How to make the result of Piecewise be a closed interval?

Description This question comes from two questions. Namely Q1 and Q2 The defintion of B-Spline basis function as shown below: Let $\vec{U}=\{u_0,u_1,\ldots,u_m\}$ a nondecreasing sequence of real numbers,i.e, $u_i\leq u_{i+1}\quad i=0,1,2\ldots m-1$ $$N_{i,0}(u)= \begin{cases} 1 & u_i\leq u NBSpline[i_Integer, 0, knots_?(VectorQ[#, NumericQ] && OrderedQ[#] &),u_] /; i Piecewise[ {{1, knots[[i + 1]] coeff[u_, i_, j_, knots_] /; knots[[i]] == knots[[j]] := 0; coeff[u_, i_, j_, knots_] := (u - knots[[i]])/(knots[[j]] - knots[[i]]) NBSpline[i_Integer, p_Integer, knots_?(VectorQ[#, NumericQ] && OrderedQ[#] &), u_] /;p > 0 && i + p Module[{init, res}, init = Table[NBSpline[j, 0, knots, u], {j, i, i + p}]; res = First@ Nest[ Dot @@@ (Thread@ {Partition[#, 2, 1], With[{m = p + 2 - Length@#}, Table[ {coeff[u, k + 1, k + m + 1, knots], coeff[u, k + m + 2, k + ...