# Tag Info

5

We can replace NIntegrate by Integrate and use FindRoot. F[x_] := 2*Pi^(-1/2)*Integrate[Exp[-y^2], {y, 0, x}] FindRoot[F[x] == 0.5, {x, 0}] {x -> 0.476936} Another way is again use NDSolve. NDSolve[{F'[x] == 2*Pi^(-1/2)*Exp[-x^2], F == 0, WhenEvent[F[x] == 0.5, {Print[x], "StopIntegration"}]}, F[x], {x, 0, ∞}] 0.476936

0

You need to improve your patterns: pair1[{___, x_, ___, x_, ___, y_, ___, y_, ___} /; x != y] := False; pair1[{___, x_, ___, x_, ___, y_, ___, y_, ___} /; x != y] := False; pair1[{___, x_, ___, x_, ___, x_, ___, x_, ___}] := False; pair1[{___, x_, ___, x_, ___, x_, ___}] := False; pair1[{___, x_, ___, x_, ___}] := True;(*a pair*) pair1[{___}] := False; pairQ[...

2

I agree, all the forms should result in the same behaviour. That the Switch/Which forms fail for RandomVariate I regard as a bug. The whole point of If,Which and Switch possessing this dual nature of being both control-flow conditionals and potentially functions is that they can be treated like the latter in cases like this. In other words, the purpose of ...

0

Many thanks for all the helpful comments. On the variance, if you don't subtract Sigma^2/2 then the mean will not be mu. The variance I meant is the variance of log returns not the variance of returns, so that is OK. I tried the numerical integration and it gives me useful results which I can plot and make sense of, which is very helpful. An analytical ...

1

This can be done numerically: f[\[Mu]_?NumericQ, \[Sigma]_?NumericQ] := NExpectation[(2 Sqrt[x])/(x + 1) - 1, x \[Distributed] LogNormalDistribution[ (\[Mu] - \[Sigma]^2/2), \[Sigma]]]; f[1, 2] -0.295453

0

It's very slow, but this is my brute force way (ignores draw order otherwise remove the Sort): cards = Flatten[Outer[List, Range@13, {♡, ♠, ♢, ♣}], 1]; numbers = cards[[All, 1]]; consecutive[hand_, n_] := Count[Differences@Sort@hand, 1] >= n - 1 numconscv = CountsBy[Subsets[numbers, {6}],consecutive[#,3]&]; numconscv[True]/Total[Values@numconscv] (* ...

0

Try first the simpler problem: solve for p, for example NSolve[CDF[BinomialDistribution[50, p], 35] == 0.025, p] // Quiet The solution is obtained right away {{p -> 0.821382}}

1

By default, Mathematica appears to use the "MethodOfMoments" method to calculate ARProcess parameters. This is involves calculating the lagged auto-covariances of the input data. However, these are likely calculated by calling the Mathematica "CovarianceFunction" function. The definition given for the covariance calculation (under "...

1

A faster option than the one in the comment flushQ[hand_] := MatchQ[hand/100 // Floor, {___, x_, x_, x_, x_, x_, ___}] Count[sortedHands, _?flushQ]/Length[sortedHands] (* 20889/1059380 *)

7

Very similar: Probability[ control < var, {control \[Distributed] BetaDistribution[24, 141], var \[Distributed] BetaDistribution[30, 151]}] 1191614106688032995829016253297371 / 1700223091652404809206230640390474 (roughly 0.7) Verify numerically: control = BetaDistribution[24, 141] var = BetaDistribution[30, 151] Count[Thread[ RandomVariate[control, ...

Top 50 recent answers are included