wolfram-mathematica

Coefficient function is slow

こ雲淡風輕ζ 提交于 2019-12-09 16:37:52
问题 Please consider: Clear[x] expr = Sum[x^i, {i, 15}]^30; CoefficientList[expr, x]; // Timing Coefficient[Expand@expr, x, 234]; // Timing Coefficient[expr, x, 234]; // Timing {0.047, Null} {0.047, Null} {4.93, Null} Help states: Coefficient works whether or not expr is explicitly given in expanded form. Is there a reason why Coefficient needs to be so slow in the last case? 回答1: Coefficient will not expand unless it deems it absolutely necessary to do so. This does indeed avoid memory explosions

Where is the location of MUnit in Wolfram Workbench 2.0 for the Mac?

你。 提交于 2019-12-09 16:36:06
问题 I have Mathematica 8.0 and Wolfram Workbench 2.0 for the Mac. I want to use MUnit to unit test a package I am creating, but I am finding the lack of documentation on MUnit to be frustrating. The best resource so for has been Mathematic Cookbook by Sal Mangano. Section 19.11 covers "Integrating Wolfram Workbench’s MUnit Package into the Frontend". I figure once I expose MUnit to the frontend, I will be able to query the MUnit API with ? . Just one problem, I can't find the MUnit package. I

DistributionFitTest[] for custom distributions in Mathematica

删除回忆录丶 提交于 2019-12-09 16:22:13
问题 I have PDFs and CDFs for two custom distributions, a means of generating RandomVariates for each, and code for fitting parameters to data. Some of this code I've posted previously at: Calculating expectation for a custom distribution in Mathematica Some of it follows: nlDist /: PDF[nlDist[alpha_, beta_, mu_, sigma_], x_] := (1/(2*(alpha + beta)))*alpha* beta*(E^(alpha*(mu + (alpha*sigma^2)/2 - x))* Erfc[(mu + alpha*sigma^2 - x)/(Sqrt[2]*sigma)] + E^(beta*(-mu + (beta*sigma^2)/2 + x))* Erfc[(

Combinations with repetition

爱⌒轻易说出口 提交于 2019-12-09 15:55:54
问题 I'm using Mathematica 7 and with a combinatorica package function I can get all combinations of a certain number from a list of elements where the order doesn't matter and there is no repetition.e.g: in: KSubsets[{a, b, c, d}, 3] out: {{a, b, c}, {a, b, d}, {a, c, d}, {b, c, d}} I cannot find a function that will give me all combinations of a certain number from a list of elements where the order doesn't matter and there is repetition. i.e. the above example would include elements like {a,a,b

Why doesn't running ClearAll[“Global`*”] from a custom Palette update local variables colors?

微笑、不失礼 提交于 2019-12-09 13:20:52
问题 I created a custom palette, with an ActionMenu that executes ClearAll["Global`*"] . It performs the desired action, but the frontend doesn't instantly update the colors from black to blue (standard), as it happens when ClearAll["Global`*"] is executed directly from a notebook cell (it only updates after something else has been executed). Is there a way to initiate a refresh of the frontend display status? EDIT: Apparently, the same happens when I load a package from a palette (blue doesn’t

How to invoke a matlab function from mathematica?

浪尽此生 提交于 2019-12-09 12:09:32
问题 I would like to call a matlab function from mathematica. How best to do that? I have found an ancient post on Wolfram site describing a way to do this, is this still the way to connect the two? 回答1: You can use mEngine. The precompiled Windows MathLink executable works with Mathematica 8. On Windows you may need to add MATLAB to the system path. The advantage of this compared to the NETLink method is that transferring variables between Mathematica and MATLAB will be as easy as mGet["x"] or

Steps to compare notebooks in Workbench

旧街凉风 提交于 2019-12-09 11:07:37
问题 What, exactly, are the steps involved in using Wolfram Workbench (version 2) to compare two notebooks? Please be explicit even in such things as what I do in order to open the two notebooks in Workbench. (I find Workbench fiendishly difficult to use. Its built-in documentation is, I find, of limited value. The tutorial screencasts about it are just too rushed to be able to follow, even with stopping and starting. And there's still a confusion, at least for me, among various versions of sample

Mathematica and MouseListener - developing interactive graphics with Mma

旧时模样 提交于 2019-12-09 10:18:32
问题 I want to add interactivity to Mathematica 3D graphics, other than with Manipulate which is cool but has its limitations. Think four example of a demo of the four cubes problem in Mathematica, a click on one of the cubes rotates a cube. Questions. Is it possible to catch MouseEvents in Mathematica graphics ( for example with using a Java class or otherwise? ) Or is the use Java then call Mathematica from Java the advised route? Or ( I hope not ) is developing interactive graphics programs

Simple text input field accepting line breaks

倾然丶 夕夏残阳落幕 提交于 2019-12-09 10:09:08
问题 Is there a simple way to get this to work? text = ""; DialogInput[{TextCell["Try to type a text with linebreaks :-)"], InputField[Dynamic[text], String], Button["Ok", DialogReturn[text]]}] The problem is that InputField terminates after typing Return . I just want a simple text input field. 回答1: Thanks for the heads-up Leonid. Here is the code: text = ""; DialogInput[{TextCell["Try to type a text with linebreaks :-)"], InputField[Dynamic[text], String, FieldSize -> {30, 6}], DefaultButton

Time efficient Partial Inverted Index building

坚强是说给别人听的谎言 提交于 2019-12-09 09:10:51
问题 I need to build a partial Inverted Index. Something like: l = {{x, {h, a, b, c}}, {y, {c, d, e}}} iI[l] (* -> {{a, {x}}, {b, {x}}, {c, {x, y}}, {d, {y}}, {e, {y}}, {h, {x}}} *) I think it is pretty clear what it does. In the input list, the {x, y ...} are unique, while the {a, b, c, ..} are not. The output ought to be ordered by #[[1]] . Right now, I am doing this: iI[list_List] := {#, list[[Position[list, #][[All, 1]]]][[All, 1]]} & /@ (Union@Flatten@Last@Transpose@list) But it looks too