wolfram-mathematica

Generating Random Non-Singular Integer Matrices

余生长醉 提交于 2019-12-12 07:56:24
问题 As part of a synthetic noise generation algorithm, I have to construct on the fly a lot of large non-singular square matrices a i,j (i,j:1..n) / ∀ (i,j) a i,j ∈ ℤ and 0 ≤ a i,j ≤ k and Det[a] ≠ 0 but the a i,j should also be random following a uniform distribution in [0, k]. In its current incarnation the problem has n ≅ 300, k≅ 100. In Mathematica, I can generate random element matrices very fast, but the problem is that I must also check for singularity. I am currently using the Determinant

Reliable clean-up in Mathematica

倾然丶 夕夏残阳落幕 提交于 2019-12-12 07:09:29
问题 For better or worse, Mathematica provides a wealth of constructs that allow you to do non-local transfers of control, including Return, Catch/Throw, Abort and Goto. However, these kinds of non-local transfers of control often conflict with writing robust programs that need to ensure that clean-up code (like closing streams) gets run. Many languages provide ways of ensuring that clean-up code gets run in a wide variety of circumstances; Java has its finally blocks, C++ has destructors, Common

mathematica exponential Nth derivative treated as an unknown function

大兔子大兔子 提交于 2019-12-12 04:38:39
问题 I'd like to create a list of Hankel functions, defined in terms of an Nth derivative, but the Nth order derivatives get treated in the way that is described in the docs under "Derivatives of unknown functions", and left unevaluated. Here's an example: Clear[x, gaussianExponential] gaussianExponential[x_] := Exp[- x^2] FullSimplify[Derivative[2][gaussianExponential[x]]] I get: (E^-x^2)^[Prime][Prime] (instead of seeing the derivatives evaluated (and the final expressions are left unsimplified)

How can I find the maximum values in each range of a list in Mathematica?

时光毁灭记忆、已成空白 提交于 2019-12-12 04:37:27
问题 I can do this in MATLAB easily but I'm trying to do it Mathematica. I have a 27000 element (15 minutes*30 measurements per second) list of wind speed values. I want to find the max value in each 2700 element (90 second) range and output it to a vector. Here is the MATLAB code: N = length(AlongWS); SegTime = 90; NSeg = (N/30)/90; Max90 = zeros(NSeg,1); Incr = N/NSeg; for i = 1:NSeg Max90(i,1) = max(AlongWS((i-1)*Incr+1:(i*Incr),1)); end Here is what I've typed in Mathematica: N = Length

Mathematica: part assignment

拟墨画扇 提交于 2019-12-12 03:52:41
问题 I'm trying to implement an algorithm to build a decision tree from a dataset. I wrote a function to calculate the information gain between a subset and a particular partition, then I try all the possible partition and want to choose the "best" partition, in the sense that it's got the lowest entropy. This procedure must be recursive, hence, after the first iteration, it needs to work for every subset of the partition you got in the previous step. These are the data: X = {{1, 0, 1, 1}, {1, 1,

R : Triple summation over function dependent on three indicies

三世轮回 提交于 2019-12-12 03:30:56
问题 I am attempting to use R to to a triple summation over a function with three indices. I was easily able to do this in Mathematica with the following code: out = Sum[B[G[[k]]] * A[G[[k]], G[[j]], G[[i]]] * prod[G[[j]],G[[i]]], {k,1,Length[G]},{j,1,Length[G]},{i,1,Length[G]}] where G is a matrix, and B[.] , A[.] , and prod[.] are all predefined functions. In Mathematica, Sum[f,{k,k_min, k_max}, {j,j_min, j_max}, {i, i_min, i_max}] would evaluate the triple sum, Sum(k=k_min, k_max)[Sum(j=j_min,

How can I import .eps in Mathematica without losing the text?

冷暖自知 提交于 2019-12-12 01:58:18
问题 I am trying to import a histogram produced by Stata as an .eps file into Mathematica , but it does not display axes' labels. That is, for some reason, Mathematica does not import .eps as but rather transforms it. How can I avoid that? As of now, I am using plain Import["~/hst.eps"] 回答1: I had a similar problem with LateX and a pdf graph recently, which also manifested itself with the eps version. I wound up modifying the user-written graphexportpdf and things seemed to work out. Perhaps you

How to plot 2 lines and spcify that the first column in list is the x-axis?

拈花ヽ惹草 提交于 2019-12-12 01:04:51
问题 I have a list that has 5 elements; {{1, 6, 4.5}, {2, 7, 4.5}, {3, 5, 5}, {4, 8, 5}, {5, 9, 5}, {6, 10, 5}} I would like to plot this so that the first column is the x-axis, and the other 2 columns would be plotted as lines. Like this: Line 1 would be have these values 6, 7, 5, 8, 9, 10 and Line 2 would be built in the same manner. I tired: ListPlot[data3, Joined -> True, Frame -> True, FrameLabel -> {"Test Number", "TS Index"}, PlotRange -> All] The resulting chart was not what I wanted. How

Customsize Background in Plot within Mathematica

那年仲夏 提交于 2019-12-11 18:36:01
问题 Considering: ListPlot[Range[10], Background -> Gray, PlotLabel -> "I don`t want the background here !"] Is there any way to have the background applied solely to the actual plotting zone? Not on the axis, not behind the label. So basically to the rectangle {{0,0},{10,10}} in that case? EDIT: Can we do the Same using PolarListPlot? Using Sjoerd Solution on From Cartesian Plot to Polar Histogram using Mathematica: dalist = {{21, 22}, {26, 13}, {32, 17}, {31, 11}, {30, 9}, {25,12}, {12, 16}, {18

Mathematica Map question

…衆ロ難τιáo~ 提交于 2019-12-11 17:34:36
问题 Original question: I know Mathematica has a built in map(f, x), but what does this function look like? I know you need to look at every element in the list. Any help or suggestions? Edit (by Jefromi, pieced together from Mike's comments): I am working on a program what needs to move through a list like the Map, but I am not allowed to use it. I'm not allowed to use Table either; I need to move through the list without help of another function. I'm working on a recursive version, I have an