# Tag Info

A nice question. Sampling from tCopula is done in stages. First a sample is generated from the copula with uniform marginal distributions, and then quantiles of appropriate marginal distributions are applied to the respective slots. Most of the time goes into evaluation of these quantiles, and they are expensive to compute. Being interested in $\geqslant ... 11 Following the method on the wikipedia page mentioned in the comments, I came up with this interp[pts_] := Module[{delta, mlst, zeropos, tau, h00, h01, h10, h11}, delta = #2/#1 & @@@ Differences[pts]; mlst = Flatten[{delta[[1]], MovingAverage[delta, 2], delta[[-1]]}]; tau = Min[#, 1] & /@ (3 delta/Sqrt[(Most[mlst]^2 + Rest[mlst]^2)]); tau ... 10 The code in Heike's answer is a bit long, but only because it does not exploit the fact that piecewise Hermite interpolation is already supported by Mathematica as Interpolation[]. Thus, here is a shorter way to implement Fritsch-Carlson monotonic cubic interpolation: fcint[data_] := Module[{del, slopes, tau}, del = #2/#1 & @@@ ... 8 Let's make a set of points: pts = Select[RandomReal[{-1, 1}, {1000, 2}], Norm[#] < 1 &]; ListPlot[pts, AspectRatio -> Automatic] Construct the density and plot it, including a contour line at the manually selected value of 0.1, all in one go: g = SmoothDensityHistogram[pts, Mesh -> {{.1}}, PlotRange -> 1.5 {{-1, 1}, {-1, 1}}] Use ... 8 Add the argument "Probability" to the Histogram command. To be precise, if list is your list of data, then Histogram[list,Automatic,"Probability"] should do the trick. The Automatic argument specifies the bin size. 7 Update: The link in the late Jens-Peer Kuska's MathGroup post is no longer working, and it seems there are no other locations on the web to download the package from. So, here I post the contents of the package with gratitute to Jens-Peer Kuska for his continuing service to the Mathematica community. Nonparametric Splines package - Jens-Peer Kuska ... 7 TransformedDistribution contains a collection of identities known to it, like that of sum of normals being equal in distribution to another normal random variable, and a general machinery to work out properties of the functions of random variables. Most of the time the computation will be done by the general machinery, which relies on solvers, like ... 7 Perhaps use UnitStep and Mean. This should be pretty fast. f[logr_, x_] := Mean[UnitStep[logr - x]] f[logr, 0] (*1597/3018*) Now to plot it. Plot[f[logr, t], {t, -.1, .1}, Exclusions -> None] 7 The natural way is to use RectangleChart since your data is already processed. I will just show how to use Histogram for your purposes, it requires step back to create the data, that's why Mike's solution is better. data = {{{0, 17}, {17, 24}, {24, 44}, {44, 64}, {64, 84}}, {86031, 26671, 91927, 93983, 32232}}; dat = RandomReal[#, ... 7 Based solely on the information provided IMO you need to use RectangleChart. I'm not sure how to create the histogram you desire using Histogram and only the information in your question -- here is the RectangleChart implementation: {widths, totals} = {{17, 7, 20, 20, 20}, {86031, 26671, 91927, 93983, 32232}}; RectangleChart[Transpose@{widths, ... 6 Alternatively you can fix both the bin end points and their heights explicitly. I've set 120 as a reasonable endpoint for the last bin. The zero in the input data is just there as a place holder and is effectively ignored. Histogram[{0}, {{0, 18, 25, 45, 65, 120}}, {86031/17, 26671/7, 91927/20, 93983/20, 32232/20} &] I would use the rectangle ... 6 With the help of comments on this and other stackexchange pages I managed to solve the problem of how to use custom distributions in things like CopulaDistribution (and other functions like RandomVariate, Expectation, etc), and given that it took me a couple of days’ hard slog I thought I’d share my discoveries with this community. Please excuse the flippant ... 6 As far as I know there are no test suites that can be invoked directly from Mathematica. One can of course use the traditional ones such as the one you mention or the NIST or the Marsaglia's diehard tests. I implemented some "toy tests" in this Wolfram Demonstration to illustrate Mathematica's various built-in PRNGs, which fail or succeed the toy tests ... 5 You could set this up in symbolic form as a bivariate distribution with pmf$f(x,y)$: Then, using the mathStatica add-on to Mathematica, the correlation you seek is: Corr[{x, y}, f]$\frac{607}{\sqrt{1467199}}$Note that this is slightly different to the solution you posted,as the numerical value is: 0.501123... (not 0.0501). You can make Mma do ... 4 If we reformulate your question as: Given a box with 30 balls, of which 10 are red, what is the probability that 4 balls drawn at random (without replacement) don't have any red balls in them you can model it by the HypergeometricDistribution: A hypergeometric distribution gives the distribution of the number of successes in$n$draws from a ... 4 list = {{3, 5}, {7, 6}, {15, 6}, {23, 123}} DeleteCases[list, {x_, _} /; x < 10] DeleteCases[list, {_?(# < 10 &), _}] Cases[list, {x_, _} /; x >= 10] Cases[list, {_?(# >= 10 &), _}] Select[list, First[#] >= 10 &] Pick[list, First[#] >= 10 & /@ list] list /. {x_, _} /; x < 10 :> Sequence[] list /. {_?(# < ... 4 The Wolfram Demonstration Project has 13 submissions that use Bayes Theorem: See here More specifically: Probability Of Being Sick After Having Tested Positive For A Disease Bayes's Theorem And Inverse Probability Total Probability And Bayes's Theorem All of these will have downloadable code to help you learn this. Good luck. 3 Assuming you have version 9 you can do the following. data = {{-1, 0}, {0, 0}, {1, 0}, {-2, 1}, {2, 1}, {-1, 3}, {1, 3}}; dist = EmpiricalDistribution[data]; Table[Expectation[y \[Conditioned] x == i, {x, y} \[Distributed] dist], {i, -2, 2}] (*{1, 3/2, 0, 3/2, 1}*) Note: Conditional probabilities and expectations didn't work for EmpiricalDistribution ... 2 I should perhaps make this post a comment and not an answer. However, I wish to fully support the comments of @AndyRoss (and have +1 his answer). cas = Cases[list, {#, y_} :> y] & /@ Range[-2, 2]; ans = {Mean[#], Mean[(# - Mean[#])^2]} & /@ cas; Style[Prepend[ MapThread[Prepend[#1, #2] &, {ans, Range[-2, 2]}], {"x", "E[Y|X=x]", ... 2 Using assumptions on the aList, namely, that all a[i]s are in the unit interval, we get symbolic results for Expectation: aList = Array[a, {6}]; errors = Array[er, 6]; answers = (Min[1, Max[#, 0]]) & /@ (aList + errors); dlist = {answers[[5]], answers[[6]], answers[[3]]/answers[[1]], answers[[4]]/answers[[2]]}; deltasbetas = Expectation[dlist, errors ... 2 If there is no way to use a "list variable" for the random vector, an explicit list of scalars can be filled in with the right distribution, thanks to @Silvia: underlying := {0.8, 0.7, 0.5, 0.4, 0.8, 0.7} answers := (Min[1, Max[# , 0]]) & /@ (underlying + {e1, e2, e3, e4, e5, e6}) dlist := {answers[[5]], answers[[6]], answers[[3]]/answers[[1]], ... 2 As @belisarius comments, the answer is usually, No, you can't do things faster by-passing built-in functions. (Sometimes the answer is yes.) Here, with the particular distribution of the OP, one can do as well by getting the explicit formula and compiling it. d = ProbabilityDistribution[Piecewise[{{x/36, 0 <= x <= 6}, {(12 - x)/36, 6 < x <= ... 1 This is not a solution or a full answer, but a hint where the slow down is. (too small to put as comment). First, I do not know probability well. I struggled to get a B in my engineering probability class (I think I should have got a B+ but that is another story). I am taking your word that TriangularDistribution[{0, 12}, 6] is exactly the same as saying ... 1 Your probability distribution is not valid. This can be seen: Probability[x > 0 || y > 0, {x, y} \[Distributed] fi] which yields 1.1 and can be seen by looking at the definition of the PMF: PDF[fi, {x, y}] This is probably a small error you can correct. Once you correct f, you can call the probability for the joint distribution (below is still ... 1 (Cannot connect to FinancialData, so I used fakeReturns instead of logr.) fakeReturns = RandomVariate[NormalDistribution[], 600]; Plot[SurvivalFunction[HistogramDistribution[fakeReturns], x], {x, -3, 3}, Exclusions -> None] Or, Histogram with Round[logr,.001] ("typical values") as bin delimiters and "SF" (i.e., SurvivalFunction) as the height ... 1 The terms in the total variation distance need to be probability distributions. Here's one way to do it: take any starting vector$m_0$(with nonzero entries that sum to$1$). You can interpret$m_0$as the initial distribution of the states. Then$m_1=m_0\cdot P$is the distribution of the states after one time step,$m_2=m_0\cdot P\cdot P$is the ... 1 You say your data is a list of$(X,Y)$so it looks like this: ListLinePlot[data, Frame -> True, FrameLabel -> {"X", "Y"}] Far from been a random coil where the definition of persistent length makes sense. Let see, we want to calculate the average$\cos(\theta) = \hat{v_1} \cdot \hat{v_1}\$, as a function of the contour distance, so I use Dot[v1, ...