Subject: Re: normal distribution random number generation > [...] > you will have modified Random to use the Wolfram rule 30 cellular > automaton and avoid the subtract with borrow algorithm. The main > consequence of this is Random will now be considerably slower. > [...] If time is an issue, you might want to consider generating integers on 0...2^n-2 instead of 0...2^n-1. It's always much faster. And if you're willing to spend a little of the time you've saved, you can add a half and avoid ever having to worry about getting a zero. In[1]:= ToString[TableForm[Table[With[{m1 = 2^n - 1, m2 = 2^n - 2}, {n, First[Timing[Do[Random[Integer,m1],{1*^6}]]]/.Second->1., First[Timing[Do[Random[Integer,m2],{1*^6}]]]/.Second->1.}], {n,2,30}],TableSpacing->{0,2}]] Out[1]= 2 1.96 1.42 3 2.12 1.5 4 2.38 1.61 5 2.66 1.73 6 2.91 1.86 7 3.16 2. 8 3.41 2.1 9 3.68 2.19 10 3.92 2.35 11 4.21 2.56 12 4.5 2.68 13 4.79 2.82 14 5.07 3.02 15 5.34 3.08 16 5.56 3.26 17 5.84 3.38 18 6.09 3.53 19 6.33 3.64 20 6.57 3.77 21 6.84 3.87 22 7.1 4.03 23 7.33 4.2 24 7.63 4.25 25 7.89 4.37 26 8.15 4.56 27 8.4 4.61 28 8.56 4.79 29 8.95 4.95 30 9.16 5.07 In[2]:= ran1 = With[{m = 2.^-30, m1 = 2^30 - 1}, Compile[{},(Random[Integer,m1]*m + Random[Integer,m1])*m]]; In[3]:= ran2 = With[{m1 = 1/(2.^30 - 1.), m2 = 2^30 - 2}, Compile[{},(Random[Integer,m2]*m1 + Random[Integer,m2])*m1]]; In[4]:= ran2h = With[{m1 = 1/(2.^30 - 1.), m2 = 2^30 - 2}, Compile[{},((Random[Integer,m2]+.5)*m1+Random[Integer,m2])*m1]]; In[5]:= First/@{Timing@Do[ran1[],{1*^5}],Timing@Do[ran2[],{1*^5}], Timing@Do[ran2h[],{1*^5}]} Out[5]= {2.03 Second, 1.05 Second, 1.08 Second} === Subject: Re: GUI for mathematica app look for GUIKit http://www.wolfram.com/solutions/guikit/ Ran Feldesh schrieb im Newsbeitrag > I'm a research student in Physics, > I've recently finished writing an application in Mathematica. > I would like to make a nice user interface for it - > a screen in which the user will insert the variables and function he > wishes to run, and get the results, insead of going into the notebook > I would like to know what the best option to do that, since I checked > and it looks to me that there is no built in way to do that. > Ran F. === Subject: Re: webMathematica and loss of context for security reasons webMathematica remove all objects in the Global` context. In your MathLink program *and* in your package you must give all symbols the proper context (not Global`) The usual is that you get patterns/symbols with Removed[someSymbol] and this match not more to the functions you have defined in your package. I had the same problem when I try MathGL3d with webMathematica for the first time. flip phillips schrieb im Newsbeitrag >I have a strange situation that is clearly pilot error and was > wondering if this was something others have seen before / could > identify a place to look for a solution. > I have a package called Human`. Human is a MathLink executable > (Fortran of all things :) and a bunch of .m wrapper and support > routines. (It isn't important here, but it is a very complete human > physiological model I am helping a fellow faculty migrate to > Mathematica) It is put together in traditional WRI recommended style. > There is an init.m with DefinePackage[], etc. I'm skeptical the > MathLink component is causing any problem, but include a reference to > it for completeness. > I have included it as part of a webMMa 2.1 page (generated via the > excellent webMMa author palette) via Needs[Human`] > The first time through everything works as expected. The executable > (called MHuman) launches, the MathLink communication takes place, > answers are returned, joy is obtained. > The -second- time the page is evaluated there is a seeming problem. > All of the Human routines have now lost their space in the global > context and don't evaluate. I verified this by embedding a call to > Names[Human`*] within the page. The first time through, Names[] > returns all of the un-context-qualified names, i.e. HumanRun, > HumanCondition, HumanKill (I know, I know...) and all works as > advertised... > The second time through, however, the call to Names[] returns > Human`Being`HumanRun, Human`Being`HumanCondition, etc... and calls to > HumanRun[10] return unevaluated. > Restarting the kernel through the KernelMonitor allows me to run it > once again, etc. > Is there somewhere obvious I am missing? === Subject: Re: long evaluation time Because Minimize isn't evaluating it at all (I think). It's lost in never-never land. Timing[NMinimize[ {(x + x^2)/(1 + y^2) + (y + y^2)/(1 + z^2) + (z + z^2)/(1 + x^2), x > 0 && y > 0 && z > 0}, {x, y, z}]] {0.046999999999997044*Second, {0., {x -> 0., y -> 0., z -> 0.}}} Bobby > Hi everybody! > Can anyone explain me, why it takes so long to evaluate > Minimize[ > (x + x^2)/(1 + y^2) + (y + y^2)/(1 + z^2) + (z + z^2)/(1 + x^2), > x > 0 && y > 0 && z > 0, > {x,y,z} > thx, _n3g -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: long evaluation time What do you think it should not take long? The answer is obviously 0 at {0,0,0}, which can be easily proved by most reasonably competent human beings. Nminimize can also do it: NMinimize[{(x^2 + x)/(y^2 + 1) + (z^2 + z)/(x^2 + 1) + (y^2 + y)/(z^2 + 1), x > 0 && y > 0 && z > 0}, {x, y, z}] {0., {x -> 0., y -> 0., z -> 0.}} though nothing NMinimize does constitutes a proof. But Minimize returns only exact results,and when it returns an answer then (barring of course bugs) it is the equivalent of a proof. To solve this kind of non-linear problem it relies on a famous algorithm, due to Collins, known as Cylindirical Algebraic Decomposition. However, the running time of this algorithm is doubly exponential in the number of variables, so you rarely can expect it to deal with more than 2 variable problems. If you reduce the number of variables by substituting something for one of them, you will get an answer in reasonable time, vis: Minimize[{(x^2 + x)/(y^2 + 1) + (z^2 + z)/(x^2 + 1) + (y^2 + y)/(z^2 + 1), x > 0 && y > 0 && z > 0} /. z -> 1/2, {x, y}] Minimize::wksol:Warning: There is no minimum in the region described by the contraints; returning a result on the boundary. {3/4, {y -> 0, x -> 0}} > Hi everybody! > Can anyone explain me, why it takes so long to evaluate > Minimize[ > (x + x^2)/(1 + y^2) + (y + y^2)/(1 + z^2) + (z + z^2)/(1 + x^2), > x > 0 && y > 0 && z > 0, > {x,y,z} > thx, _n3g Andrzej Kozlowski Chiba, Japan http://www.akikoz.net/~andrzej/ http://www.mimuw.edu.pl/~akoz/ === Subject: Export with jLink I want to use the power of mathematica from java. I would like to extract data from a database (oracle), make some calculations, creates plots and put those plots in a pdf file. I created a mathematica package which generates plots and export them in .wmf files. This works when the package is executed in mathematica, but when this package is called from java with jLink, empty wmf files are created. Jerome Jerome Beauquis CERN / AT-MAS / 1211 Geneva 23 Switzerland Office : 112/04-015 Phone : (+41) 22 767 3136 Mailbox : M07400 E-mail : jerome.beauquis@cern.ch === Subject: Re: no line PlotStyles with ParametricPlot3D ? > You could use the unintuitive feature of putting graphics primitives in the > parametrization (and by the many questions on this it is a frequent source > of confusion to users) dissimilars can be so clubbed together. Perhaps you can give one mega example of what all features could still jump onto the 3D graphics bandwagon.. :) > xyz = {Cos[t] Cosh[t], t + Tanh[t], > Sin[t]Cosh[t], {RGBColor[1, 0, 0], Thickness[.01]}}; > ParametricPlot3D[xyz, {t, 0, 2 Pi} ]; > Or you could more intuitively use DrawGraphics > Needs[DrawGraphics`DrawingMaster`] > xyz = {Cos[t] Cosh[t], t + Tanh[t], Sin[t]Cosh[t]}; > Draw3DItems[ > {Red, Thickness[0.01], > ParametricDraw3D[xyz, {t, 0, 2 Pi} ]}, > Axes -> True]; Shall try when I get a higher version. > But there a use of the 'directives in the parametrization' in that you can > vary them as a function of t. > xyz = {Cos[t] Cosh[t], t + Tanh[t], > Sin[t]Cosh[t], {Hue[t/(2Pi)], Thickness[0.01]}}; > ParametricPlot3D[xyz, {t, 0, 2 Pi} ]; Hue looks nice,like some mysteriously glowing laser tube or linear rainbow. > xyz = {Cos[t] Cosh[t], t + Tanh[t], Sin[t]Cosh[t]}; > Draw3DItems[ > {Thickness[0.01], > ParametricDraw3D[ > Join[xyz, {Hue[t/(2Pi)]}] // Evaluate, {t, 0, 2 Pi} ]}, > Axes -> True]; === Subject: Re: Constraints to parameters in FindFit? For sign restiction an old trick is to use instead of paramold the expression Exp[paramnew] or -Exp[paramnew] in your model, and search for paramnew (instead of paramold). P. > Hi All, > I am using FindFit to fit a series of peaks to some data. I would like > to be able to constrain some of the parameters of my fit to correspond > to physical reality. For example, some peaks should have a negative > amplitude, others positive, where the amplitudes are the parameters > that Mathematica is finding in FindFit. The peaks are all very near > each other, so without any constraint, it is making the wrong ones > negative. I'd like to specify that a given parameter should always be > negative. I am already giving an initial guess of the proper sign, but > it doesn't fix the problem. > Jill. === Subject: Re: Constraints to parameters in FindFit? Jill Foley, PhD Princeton Plasma Physics Lab tel. (609) 243-0000 fax (609) 243- 0000 E-mail: Jill, You should use NMinimize, or one of the third party optimization packages, instead of FindFit (an unconstrained local optimizer). In the fcts and packages referred to, you can specify constraints on the dec vars. I am the principal developer of MathOptimizer and MathOptimizer Professional: you can see those at WR's site, also directly available from my company. For theoretical background, please see my book 'Global Optimization in Action' as well as my more recent papers. Janos _________________________________________________ Janos D. Pinter, PhD, DSc President & Research Scientist, PCS Inc. Adjunct Professor, Dalhousie University 129 Glenforest Drive, Halifax, NS, Canada B3M 1J2 Telephone: +1-(902)-443-5910 Fax: +1-(902)-431-5100; +1-(902)-443-5910 E-mail: jdpinter@hfx.eastlink.ca Web: www.pinterconsulting.com www.dal.ca/~jdpinter Software products: http://www.pinterconsulting.com/Software_Sum_Info.pdf >Hi All, >I am using FindFit to fit a series of peaks to some data. I would like >to be able to constrain some of the parameters of my fit to correspond >to physical reality. For example, some peaks should have a negative >amplitude, others positive, where the amplitudes are the parameters >that Mathematica is finding in FindFit. The peaks are all very near >each other, so without any constraint, it is making the wrong ones >negative. I'd like to specify that a given parameter should always be >negative. I am already giving an initial guess of the proper sign, but >it doesn't fix the problem. >Jill. === Subject: Re: Re: No more memory available > It is stack={{{{{},d},c},b},a}. > In the meantime I measured the depth of the stack and it is normal, I > mean it is mostly below 100 during a run. So, I was wrong in my > assumption that my stack is getting too deep. My apology... I ran > out of memory, because the results - different length of strings - I > collect in a simple list is getting too big. > I will try to compress or pack them before I add them to the list. > In the meantime as I investigated the Depth[of different objects], I > found that I can crash the kernel with no exception on both of my > machines with the following one liner: > Depth[Fold[List, , Table[, {i, 87363}]]] > I looked the Book, but found no limit on nesting other than > $RecursionLimit, but that one does not apply here looks like anyway. > So the biggest depth an object can have without crashing the kernel in > 5.0.1 is 87361. Interestingly it is a multiplicand of two primes 199 > and 439. > J.87nos > [...] In many places in the Mathematica code base recursion is used. Depth is an obvious candidate. This has the unfortunate effect of exploding the subroutine stack when manipulating deeply nested expressions. Several years ago (for version 3.0.1, I believe) I fixed this for a few important and commonly used functions such as Flatten, LeafCount, and our expression freeing code, by using an explicit stack internally to avoid the operating system (and maybe compiler) dependent subroutine stack. (At least one or two other people contributed to that work so I don't want to claim all the credit, or blame, in case people noticed a slight slowdown.) Anyway, this was not done for all imaginable functions. Possibly we should consider handling a few more in that way. Offhand I'm not sure how common it is to do such things as Depth on deeply nested expressions. I do not know if there is some OS-dependent significance to the fact that 87361 = 199*439, but clearly it had to be a product of SOME primes. Daniel Lichtblau Wolfram Research === Subject: Re: Conveniently Restarting Notebooks Hope this is not off the point too much. I never understood why the notebook front end allows you to play in multiple windows with the same kernel, to jump around within each of them, and between them, yielding a nonlinear sequence of Ins and Outs, and why the calculation order, nor which (other) notebooks are involved in the project, is not saved at all, hence cannot be recovered. The front end is fantastic of course for scientific communication. I have still some complaints. 1. Once in a while the In-Out combinations go astray, and the corresponding Out of an In is not overwritten, but pushed down. Don't know when/why that happens. I can't get rid of it. It spreads through the whole notebook. 2. I started using mixed color font coding within identifiers, say to highlight word segments like Global or Default. After a while tiny white space gets between the colors, and the Find (Ctrl + F) utility cannot retrieve the whole words anymore. Had to stop doing that. Find needs more options, whole words, formatting, color. 3. I create input cells spreading over multiple screens, extensively using Maeder's Class mechanism. If you edit inside these inputs, unbalanced parentheses or brackets cause the text to scroll unpredictably and the cursor to jump from top to bottom to the middle and so forth. Each time you have to find back the cursor. Then you type the closing bracket and bang again. Gone. If you have to do that for hours you go completely nuts. I like the horizontal scrolling with unmatched parentheses, but would like to see the thing stabilized in the vertical direction, when you are just typing within a line. Tom Tom Aldenberg RIVM PO Box 1 NL-3720 BA Bilthoven Netherlands T: +31 30 2743137 F: +31 30 2744413 E: tom.aldenberg@rivm.nl === Subject: Very basic question: Zoom into a 2-D plot with the mouse I have a very basic question: Does Mathematica offer the possibility to zoom into a plot (e.g. a simple 2-D plot like the result of Plot[Sin[x],{x,0,2*Pi}]) by using the mouse? I am talking about a feature that many other tools offer. I know that one can use the PlotRange option to zoom into a plot region, but it can be quite awkward for every zoom to use this option. Rainer === Subject: Re: Re: Problem with Maximize and conditions. Is this what you meant to enter in your e-mail? Minimize[{x + y + z, {(1/20)*x + y + 5*z >= 100, (1/20)*x + y + 5*z <= 102, x [Element] Integers, y [Element] Integers, z [Element] Integers, 0 < x < 99, 0 < y < 99, 0 < z < 99}}, {x, y, z}] {22, {x -> 1, y -> 1, z -> 20}} I had to guess what ≥, ≤ and ∈ represent. For things like this, I recommend Omega Consulting's Copy as InputForm palette at http://eclecticdreams.net/DrBob/copy_as_inputform.htm or Ingolf Dahl's palette at If I guessed the right substitutions, tightening the second inequality gives the following under version 5.0.1 (with no kernel crash): Minimize[{x + y + z, {(1/20)*x + y + 5*z >= 100, (1/20)*x + y + 5*z <= 101, x [Element] Integers, y [Element] Integers, z [Element] Integers, 0 < x < 99, 0 < y < 99, 0 < z < 99}}, {x, y, z}] {25, {x -> 1, y -> 5, z -> 19}} Bobby > Of course Steve was the one who solved the problem by introducing > Reduce. Using it inside the Minimize command is a smart move, but it > does not change the fact: the reduce function explicitely prepares the > whole set of feasible solutions. > As Janos Pinter and others have pointed out, complete enumeration > works for the little example in question, but it cannot be used for > larger problems. > example as > Minimize[{x + y + z, {1/20 x + y + 5z ≥ 100, 1/20 x + y + 5z > ≤ 102, x > ∈ Integers, y ∈ Integers, z ∈ Integers, 0 > < x < 99, 0 < > y < 99, 0 < z < 99}}, {x, y, z}] > This works fine and gives the correct solution > {22, {x -> 1, y -> 1, z -> 20}} > Unfortunately, when I make the second inequality stronger, that is > 1/20 x + y + 5z ≤ 101 > then MathKernel encounters a problem and has to close (while being > sorry for the inconvenience.) > Appearantly, Minimize uses the Gomory-algorithm, reducing the integer > LP into a series of classical LP problems, but somewhere on the road > it crashes. This is a simple bug and I think the given example will > help the developer to find it. > Peter >> Yes, I knew that, because my first reply listed the full output of Reduce! >> However, I overlooked the possibility that immediately substituting this >> output back into Minimize would work. >> Steve Luttrell >>> It seems >>> that the conditions you feed to Minimize are improved by being >>> wrapped in >>> Reduce. >>> Well, they are not just improved but actually Reduced to >> triviality. Reduce does all the work and Minimize is only left with >> something that looks like this (except that with more terms) >> Minimize[x + y + z, {x == 20 && y == 4 && z == 19 || >> x == 20 && y == 9 && z == 18}, {x, y, z}] >> This sort of thing even Minimize can manage;-) >> Andrzej Kozlowski >> Chiba, Japan >> http://www.akikoz.net/~andrzej/ >> http://www.mimuw.edu.pl/~akoz/ >> -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Factor 2 error in Inverse Laplace Transform InverseLaplaceTransform is an extremely useful part of Mathematica (since v 4.1). However, in the following simple problem it gives the wrong answer: Problem 1: InverseLaplaceTransform[s/(s+1),s,t] -1/(2*E^t)+DiracDelta[t] where the factor 2 is completely wrong. To see that I slightly rewrite Problem 1 into Problem 1a: InverseLaplaceTransform[Apart[s/(s+1)],s,t] and then I get the correct answer: -E^(-t)+DiracDelta[t] Of course one can Unprotect InverseLaplaceTransform and teach it to give the correct answer but that is not the point. (Also one can start a long debate about the meaning of DiracDelta in Mathematica, but that is also not the point here. ) There are several similar simple examples when the wrong factor of two shows up, for instance Problem 2: InverseLaplaceTransform[ s ArcTan[1/s],s,t] Using the Trace one can find out that all these factor 2 errors have a common origin. Solving Problem 1 Mathematica calculates the convolution integral Integrate[E^(-t+x)*Derivative[1][DiracDelta][x],{x,0,t}] and because the lower limit is exactly zero,the factor 2 shows up in -1/(2*E^t), that is Mathematica halves the Dirac delta and all its derivatives at the origin. I think the InverseLaplaceTransform function could be much improved if the above convolution integral would be evaluated more carefully. For instance, doing it in two steps: res1=Integrate[E^(-t+x)*Derivative[1][DiracDelta][x],{x,-eps,t}, Assumptions -> eps>0]; res2=res1/.eps -> 0 would give the right result. (This caution is necessary only, if generalized functions are involved in the integration.) I wonder if further examples/suggestions are welcome in this group regarding InverseLaplaceTransform??? Peter === Subject: Re: Conveniently Restarting Notebooks Tom, Various people have their methods of using notebooks and it's not for me to say that some person's method that works for them is wrong. Still I often see some practices that appear to me to make things more difficult rather than easier. The object is to use notebooks in a way that simplifies one's own work and facilitates communication with other people. Complicated schemes usually frustrate this purpose. When using Mathematica notebooks as a means of communication, you can't expect that readers will understand any complicated nonstandard scheme no matter how nifty it may seem to you. The question is: Do you want to get to the subject matter, or do you want to manage a complicated notebook scheme? (I like to watch opera and ballet and one of my pet peeves is excessive panning and zooming of the camera. Fred Astaire used to say that either the camera dances or he dances but not both. Do you want your discussion and calculations to do the dancing or do you want the notebook style to do the dancing?) I think that every notebook should be self contained. It may depend on packages but shouldn't depend on other notebooks. The only time I have two notebooks open at once is when I'm copying some material from one notebook to another, or when I'm changing a package notebook and testing with a regular notebook. Use only one each, at most, of the various title cells and put them at the top of the notebook. Use Sections as the main organizational method. For discussion and comments use Text cells, not the various types of Section or Title headers. I've had cases where new output cells did not overwrite the old output cells. But it is very rare and I'm not certain what the cause is. I usually just delete all the output cells and reevaluate and the problem goes away. I usually delete all output cells before I save a notebook and I think the problem may occur more often when a notebook is opened with existing output cells. Maybe other people have experience on this. I wouldn't use a lot of font colors in input cells, or a lot of color coding in notebooks. Is the color coding actually adding syntatical information or is it just decorative? Color schemes are not natural or intuitive in the sense that certain colors mean certain things - especially technical things. It's rather a burden to maintain, probably stresses the FrontEnd and parser, and will probably be lost on readers of your notebooks. It's an example of a notebook style dancing. I don't know what to say about your last problem. I must work on simple things because I never have an Input cell that extends over multiple screens. Do you actually type in a single multiple screen input cell? It sounds like it would be more managable if it could be broken into pieces. Functions of functions or something like that. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Hope this is not off the point too much. I never understood why the notebook front end allows you to play in multiple windows with the same kernel, to jump around within each of them, and between them, yielding a nonlinear sequence of Ins and Outs, and why the calculation order, nor which (other) notebooks are involved in the project, is not saved at all, hence cannot be recovered. The front end is fantastic of course for scientific communication. I have still some complaints. 1. Once in a while the In-Out combinations go astray, and the corresponding Out of an In is not overwritten, but pushed down. Don't know when/why that happens. I can't get rid of it. It spreads through the whole notebook. 2. I started using mixed color font coding within identifiers, say to highlight word segments like Global or Default. After a while tiny white space gets between the colors, and the Find (Ctrl + F) utility cannot retrieve the whole words anymore. Had to stop doing that. Find needs more options, whole words, formatting, color. 3. I create input cells spreading over multiple screens, extensively using Maeder's Class mechanism. If you edit inside these inputs, unbalanced parentheses or brackets cause the text to scroll unpredictably and the cursor to jump from top to bottom to the middle and so forth. Each time you have to find back the cursor. Then you type the closing bracket and bang again. Gone. If you have to do that for hours you go completely nuts. I like the horizontal scrolling with unmatched parentheses, but would like to see the thing stabilized in the vertical direction, when you are just typing within a line. Tom Tom Aldenberg RIVM PO Box 1 NL-3720 BA Bilthoven Netherlands T: +31 30 2743137 F: +31 30 2744413 E: tom.aldenberg@rivm.nl === Subject: Mini-Courses Provide Specialized Mathematica Training Online Wolfram Education Group has expanded its Mathematica training course offerings with the launch of several new online mini-courses taught by core developers at Wolfram Research. These three-to-four hour sessions provide intensive hands-on instruction from home or work in specific Mathematica applications such as statistical analysis, numerical computation, technical authoring, and applied programming. Participants also have the opportunity to learn from the developers themselves about new and emerging technologies -- including webMathematica, gridMathematica, J/Link, .NET/Link, and Web Services Package -- as soon as they are developed. Additional courses are continually being produced based on feedback and requests from the user community. For more information, go to: http://www.wolfram.com/services/education/minicourses === Subject: Re: Need Help: 1st order nonlinear differential equation That's totally unreadable. I recommend Omega Consulting's Copy as InputForm palette: http://eclecticdreams.net/DrBob/copy_as_inputform.htm Bobby > I need to solve the following 1st order nonlinear differential > equation. I am really stuck. DSolve refuses to give an answer and I > need an algebraic solution. > Derivative[1][a][Z] == > -((1/n + ((r*(n - 1))/(n^2*a[Z]))*((1 - a[Z])*n - (åÏÌÎ + 2*åÏÌ.b3)*Z))/ > (r*(n - 1)*((n*(r - 1) - 2*r)/(n^2*a[Z]^2))*Z*((1 - a[Z])*n - > åÏÌ.b3*Z))) > where > !({0 åÁÌ[Thorn] a åÁÌ[Thorn] 1, Z åÁÌÿ 0, n > 2, 1 > åÏÌ.b3 > 0, 1 > åÏÌÎ > 0, 1 > r 0, 0 < r < n/(n - 2)}) > Does anybody know how to solve this problem? Has anybody tips how to > impose domain restrictions while solving differential equations in > Mathematica (version 5.0.1.0.)? > Maybe I am thinking slow but I am really in trouble. > Respectfully; > Wolfgang -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Variance of sample and whole dataset In other words, you can use VarianceMLE and StandardDeviationMLE. Bobby > Look at Help browser in add-ons Statistics|Descriptive Statistics. You'll > find there what you want. > Tomas Garza > Mexico City > ----- Original Message ----- === > Subject: Variance of sample and whole dataset >> with Variance[list] and StandardDeviation[list] I get the >> variance/std.dev for samples. >> Is there any builtin command for the variance of whole dataset (division >> by n, not by n-1)? >> Uwe >> -- >> mail to newsgroup@ziegenhagen.info is read only from time to time. If -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Occurrence of a substring inside a list of strings Possibly StringMatchQ yields a nicer solution. lst = {abc, abcd, aabccaddbacdda, adbacca}; frag = cca; boole[True] = 1; boole[a_] = 0; superString::usage = superString[ a][b] returns 1 if b is a super-string of a (a is a substring of b), else 0.; superString[frag_String][ a_String] := boole@StringMatchQ[a, * <> frag <> *] Total[superString[frag] /@ lst] Tr[superString[frag] /@ lst] Plus @@ (superString[frag] /@ lst) 2 2 2 Bobby > I have a simple list of strings like lst={abc, abcd, > aabccaddbacdda, adbacca,....}. Let's say I have a fragment called > frag=dba. I would like to know how many strings in lst contain > minimum once the fragment frag. > This is what I did: > Length[Flatten[Map[Part[StringPosition[#, frag], All, 1] &,lst] ] ] > Is there a better/faster way to calculate it ? > J.87nos > ---------------------------------------------- > Trying to argue with a politician is like lifting up the head of a > corpse. > (S. Lem: His Master Voice) -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Occurrence of a substring inside a list of strings Andrzej, Elegant is the winner. On a list with length 294773 and ByteCount 1626134432 - on a 2GB memory G4 machine top showed just 21MB free memory, a typical condition - I got the following results /the first is my newbie one/: In[26]:= Length[Flatten[Map[Part[StringPosition[#,fragment1],All,1]&,collectedDna Bin]]] //Timing Out[26]= {559.01 Second,12} In[30]:= Count[(StringPosition[#1, fragment1, 1] & ) /@collectedDnaBin, _?(#1 != {} & )]//Timing Out[30]= {558.78 Second,12} In[31]:= Length[Join @@ (StringPosition[#1, fragment1, 1] & ) /@collectedDnaBin]//Timing Out[31]= {557.75 Second,12} In[33]:= Count[collectedDnaBin, _?(StringMatchQ[#1, StringJoin[*, fragment1, *]] & )]//Timing Out[33]= {114.09 Second,12} having fragment1 as a 100 character long string. J.87nos >> *This message was transferred with a trial version of CommuniGate(tm) >> Pro* >> I have a simple list of strings like lst={abc, abcd, >> aabccaddbacdda, adbacca,....}. Let's say I have a fragment called >> frag=dba. I would like to know how many strings in lst contain >> minimum once the fragment frag. >> This is what I did: >> Length[Flatten[Map[Part[StringPosition[#, frag], All, 1] &,lst] ] ] >> Is there a better/faster way to calculate it ? >> J.87nos >> ---------------------------------------------- >> Trying to argue with a politician is like lifting up the head of a >> corpse. >> (S. Lem: His Master Voice) > I am not sure about better or faster (it is quicker to write this > sort of program than to test how fast it is). One can produce lots of > version using ideas similar to yours, e.g. > Count[(StringPosition[#1, frag, 1] & ) /@ lst, _?(#1 != {} & )] > or > Length[Join @@ (StringPosition[#1, frag, 1] & ) /@ lst] > But the method that seems the most elegant to me (I have not tested it > for speed though) is: > Count[lst, _?(StringMatchQ[#1, StringJoin[*, frag, *]] & )] > Andrzej Kozlowski > Chiba, Japan > http://www.akikoz.net/~andrzej/ > http://www.mimuw.edu.pl/~akoz/ ------------------------------------------ The shortest route between two points is the middleman Ayn Rand === Subject: Re: Occurrence of a substring inside a list of strings > *This message was transferred with a trial version of CommuniGate(tm) > Pro* > I have a simple list of strings like lst={abc, abcd, > aabccaddbacdda, adbacca,....}. Let's say I have a fragment called > frag=dba. I would like to know how many strings in lst contain > minimum once the fragment frag. > This is what I did: > Length[Flatten[Map[Part[StringPosition[#, frag], All, 1] &,lst] ] ] > Is there a better/faster way to calculate it ? > J.87nos > ---------------------------------------------- > Trying to argue with a politician is like lifting up the head of a > corpse. > (S. Lem: His Master Voice) I am not sure about better or faster (it is quicker to write this sort of program than to test how fast it is). One can produce lots of version using ideas similar to yours, e.g. Count[(StringPosition[#1, frag, 1] & ) /@ lst, _?(#1 != {} & )] 2 or Length[Join @@ (StringPosition[#1, frag, 1] & ) /@ lst] 2 But the method that seems the most elegant to me (I have not tested it for speed though) is: Count[lst, _?(StringMatchQ[#1, StringJoin[*, frag, *]] & )] 2 Andrzej Kozlowski Chiba, Japan http://www.akikoz.net/~andrzej/ http://www.mimuw.edu.pl/~akoz/ === Subject: Re: Occurrence of a substring inside a list of strings > I have a simple list of strings like lst={abc, abcd, > aabccaddbacdda, adbacca,....}. Let's say I have a fragment called > frag=dba. I would like to know how many strings in lst contain > minimum once the fragment frag. > This is what I did: > Length[Flatten[Map[Part[StringPosition[#, frag], All, 1] &,lst] ] ] > Is there a better/faster way to calculate it ? Count[lst, s_ /; StringMatchQ[s, * <> frag <> *]] seems to be faster... -- 0% de pub! Que du bonheur et des vrais adh.8erents ! Vous aussi inscrivez-vous sans plus tarder!! Message post.8e .88 partir de http://www.gyptis.org, BBS actif depuis 1995. === Subject: Re: Re: Colors in ScatterPlot3D? That doesn't happen with my Mathematica 5.0.1 WinXP installation, but apparently it does on your machine. Go figure. I'd try wrapping Evaluate around Transpose, or around the List that's a part of, since the error message indicates red isn't evaluated soon enough. Another possibility is that red didn't get defined because of a spelling error (though you didn't mention any), since Red is a symbol in Graphics`Colors`. I include Off[General::spell] Off[General::spell1] in my Init.m, so that never happens to me. Bobby >> The option should be: >> PlotStyle -> (RGBColor[#, 0, 0] & /@ colortable) >> But that still gives the first color for all the points. >> This works, however: >> atable = Table[Random[Integer, {1, 10}], {50}, {3}]; >> colortable = Table[Random[Real, {0, 1}], {50}]; >> red = RGBColor[#, 0, 0] & >> Show[Graphics3D@{PointSize[.02], Transpose@{red /@ >> colortable, Point /@ atable}}] >> Bobby > This results in the following error message along with a System crash: > Graphics3D::gprim: red[0.868505] was encountered where a Graphics3D > primitive or directive was expected.... > Klaus G. -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Reads in only part of file >Steve, use the option DOSTextFormat -> True. This an option of >OpenStream so you must do >stream = OpenStream[ st1, DOSTextFormat -> True] xin = >ReadList[stream, {Byte, Byte}] No, the option needs to be DOSTextFormat->False. When set to true (the default condition) this causes Mathematica to interpret the stream as text, i.e., translating line-ending characters into newline characters and terminating on an EOF character. This is exactly the behavior you want to avoid when reading non-text files. -- === Subject: symbol replace I am facing 2 problems with Mathematica: 1st problem) With replace all command, when I use it with subscripts I get an unintended effect, this is what I do: E * (Eo) /. E -> (Eo) I intend to replace only E with Eo, but Mathematica instead replaces all E's with (Eo) and I get this instead: (Eo) * (Eo)o Please note the 'o' in Eo is supposed to be a subscript here and reads Enot. Can anyone please help? here is the Mathematica code: In[1]:= !(E * E_0 /. E -> E_0) Out[1]= !([ExponentialE]_0 (([ExponentialE]_0))_0) 2nd problem) I like to use descriptive names for my variables with Underscore to separate the names, it's really easier to read, but of course underscore is a special character in Mathematica unfortunately, so is there an alternative?? For example, I like to use variable Dynamic_Energy_of_Stars_With_Sand = 123; Is there something else equally as obvious as Underscore that maybe used for purpose of separting words in a variables names??