wolfram-mathematica

Fitting parameter b of the Gamma distribution from mean, 95% in Python

白昼怎懂夜的黑 提交于 2020-01-15 10:13:09
问题 This Mathematica function finds parameter b of the Gamma distribution, given mean and 95% values and scaled by the mean [Mu]; The two values bracket [Beta] makes it fast and there is a restriction for max pg95= 5.8[Mu]* gb[[Mu] , p95 ]. I need to translate this code into Python: gb[\[Mu]_, p95_] := Block[{p = Min[p95/\[Mu], 5.8]}, \[Mu] FindRoot[CDF[GammaDistribution[1/\[Beta], \[Beta]], p] - .95 == 0, {\[Beta], 1, If[p == 1, 1.1, p]}][[1, 2]]]; 回答1: Even if you cannot find exactly equivalent

Not cropping BarChart when using Frame instead of Axes

余生长醉 提交于 2020-01-15 06:32:10
问题 I just found out that a BarChart may get cropped when using Frame rather than Axes . Example: data = {.2, .4, .6, 0., 0., 0.} BarChart[data] BarChart[data, Frame -> True, Axes -> False] Is this a feature or a bug? If it is a feature, is there an easy way to prevent cropping? EDIT Screenshot, per request: 回答1: Well, It was not always like that: 回答2: How about using PlotRange ?... data = {.2, .4, .6, 0., 0., 0.} BarChart[data] BarChart[data, Frame -> True, Axes -> False, PlotRange -> {{.5, 6.5}

How to parallelize integrating in Mathematica 8

徘徊边缘 提交于 2020-01-13 14:59:56
问题 Somebody have idea how to use all cores for calculating integration? I need to use parallelize or parallel table but how? f[r_] := Sum[(((-1)^n*(2*r - 2*n - 7)!!)/(2^n*n!*(r - 2*n - 1)!))* x^(r - 2*n - 1), {n, 0, r/2}]; Nw := Transpose[Table[f[j], {i, 1}, {j, 5, 200, 1}]]; X1 = Integrate[Nw . Transpose[Nw], {x, -1, 1}]; Y1 = Integrate[D[Nw, {x, 2}] . Transpose[D[Nw, {x, 2}]], {x, -1, 1}]; X1//MatrixForm Y1//MatrixForm 回答1: If one helps Integrate a bit by expanding the matrix elements first,

Formatting numbers when writing to files in Mathematica

泪湿孤枕 提交于 2020-01-13 09:54:13
问题 This is a continuation of this question regarding number formatting, and related to my earlier question about obtaining very specific Mathematica output to text files. I frequently have to use high precision in Mathematica for data generation but only need relatively low precision for visualization purposes. I also want to store the data for later use with all Symbol names and Array structures intact. For this I have been using Save[] , but there are two related problems. The high precision

How can I convert .eps file to .pdf in Mathematica?

你离开我真会死。 提交于 2020-01-13 06:14:50
问题 How can I convert .eps to .pdf inside Mathematica (perhaps using GhostScript?)? 回答1: After installing GhostScript and setting appropriate environment variables (for Windows you should add gs\bin and gs\lib to the PATH , where gs is the top-level Ghostscript directory) you can use Jens Nöckel's method for converting .eps to .pdf (all the glyphs will be outlined): gsEPS2PDF[epsPath_String, pdfPath_String] := Run["gswin64c.exe -sDEVICE=pdfwrite -dNOCACHE -sOutputFile=\"" <> pdfPath <> "\" -q

How can I convert .eps file to .pdf in Mathematica?

£可爱£侵袭症+ 提交于 2020-01-13 06:14:06
问题 How can I convert .eps to .pdf inside Mathematica (perhaps using GhostScript?)? 回答1: After installing GhostScript and setting appropriate environment variables (for Windows you should add gs\bin and gs\lib to the PATH , where gs is the top-level Ghostscript directory) you can use Jens Nöckel's method for converting .eps to .pdf (all the glyphs will be outlined): gsEPS2PDF[epsPath_String, pdfPath_String] := Run["gswin64c.exe -sDEVICE=pdfwrite -dNOCACHE -sOutputFile=\"" <> pdfPath <> "\" -q

Mathematica: MathLink error messages

折月煮酒 提交于 2020-01-12 17:42:32
问题 I think I am starting to understand how to link functions written in C/C++ to Mathematica . The problem I'm facing is that I don't know how to send error messages from my C wrapper to Mathematica. After searching in google I found this MathLink Tutorial. Section 1.7 gave me an insight as to how to send error messages but I am getting weird results. Here is the code I am working with. //File cppFunctions.h #ifndef CPPFUNCTIONS_H #define CPPFUNCTIONS_H class Point { public: double x, y; Point()

Mathematica: MathLink error messages

…衆ロ難τιáo~ 提交于 2020-01-12 17:42:30
问题 I think I am starting to understand how to link functions written in C/C++ to Mathematica . The problem I'm facing is that I don't know how to send error messages from my C wrapper to Mathematica. After searching in google I found this MathLink Tutorial. Section 1.7 gave me an insight as to how to send error messages but I am getting weird results. Here is the code I am working with. //File cppFunctions.h #ifndef CPPFUNCTIONS_H #define CPPFUNCTIONS_H class Point { public: double x, y; Point()

Error generating localized variables (as constants)

和自甴很熟 提交于 2020-01-12 17:25:02
问题 The usage message for Set reminds us that multiple assignments can easily be made across two lists, without having to rip anything apart. For example: Remove[x1, x2, y1, y2, z1, z2]; {x1, x2} = {a, b} Performs the assignment and returns: {a, b} Thread , commonly used to generate lists of rules, can also be called explicitly to achieve the same outcome: Thread[{y1, y2} = {a, b}] Thread[{z1, z2} -> {a, b}] Gives: {a, b} {z1 -> a, z2 -> b} However, employing this approach to generate localized

How to Label Graph Edges with their weights

試著忘記壹切 提交于 2020-01-12 05:30:10
问题 Warning! I posted the question when Mathematica v 8.0 was the coolest kid. The bug has been solved as of version 9.0.1 The help for EdgeLabels states: However: CompleteGraph[4, EdgeWeight -> Range@6, VertexShapeFunction -> "Name", EdgeLabels -> "EdgeWeight"] Results in: So, no Edge Labels ... I guess it is a bug. I used a nasty construct like: adj = {{\[Infinity], 1, 1, 1, 1}, {1, \[Infinity], 2, 2, 2}, {1, 2, \[Infinity], 2, 2}, {1, 2, 2, \[Infinity], 2}, {1, 2, 2, 2, \[Infinity]}};