Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
21 views

Simulating data from a piecewise pdf occasionally returns an error [duplicate]

In the following code, I generate data from a piecewise PDF. Usually, I get a sample size of ns, but sometimes I get an error message: Error: RandomVariate::unsdst:...
M. Mo's user avatar
  • 9
2 votes
1 answer
100 views

How to use Mathematica to find the explicit formula of expected value of minimum of multiple uniform distributions?

...
138 Aspen's user avatar
  • 2,067
3 votes
1 answer
239 views

How to use Mathematica to find the maximum expected value of multiple normal distributions?

Is it possible to calculate the maximum expected value of $ n (n\geq 2) $ independent (identical distributed) random variables that follow a normal distribution? If possible, how to find it? If it ...
138 Aspen's user avatar
  • 2,067
1 vote
1 answer
133 views

How to quickly sample from the following distributions

Consider the following distributions: ...
John Taylor's user avatar
  • 5,963
0 votes
0 answers
42 views

Combinations of distributions to be called with `RandomVariate`

I'd like to manipulate distributions that I'm going to retrieve using RandomVariate; e.g., I would like to take ...
zjs's user avatar
  • 153
1 vote
1 answer
98 views

How can I calculate the moments of a truncated random variable?

I am using the Moment function to calculate the moments of an exponential random variable. as follows, Moment[ExponentialDistribution[3], 9] However, I need to ...
slow_learner's user avatar
4 votes
1 answer
74 views

Speeding up RandomVariate with custom probability distribution

I have the defined a custom distribution, which is a Gaussian where the exponent can be any real n greater than 0 (set to actually be >0.5 in use), i.e. ...
Xyive's user avatar
  • 115
0 votes
1 answer
94 views

How to generate random value under the given distribution fast?

Consider a distribution distr[EN_, Enu_, mN_] = Exp[-(Sqrt[EN^2 + mN^2]/Enu)]*Sqrt[(Sqrt[Enu^2-mN^2]/2)^2 - EN^2] Sqrt[ EN^4 - (Enu/4)^4] where mN is a free ...
John Taylor's user avatar
  • 5,963
5 votes
2 answers
693 views

How do you generate a random number with a pre-specified probability distribution?

I want to generate a random real number between 0 and 1 but not distributed uniformly but with a probability distribution say, 2 Sin[ pi x ]^2 which integrates to 1 ...
Quasar Supernova's user avatar
0 votes
2 answers
163 views

How to generate random dots with given distances?

I am interested in the following problem, and am curious if Mathematica could be used to solve it. I start with a radius function $\rho:D\to \mathbf{R}_{\ge 0}$ on a region $D\subseteq \mathbf{R}^n$. ...
Pulcinella's user avatar
0 votes
1 answer
84 views

Is there a difference between generating and loading data?

EDIT-1 This is a minimal example where an error occurs after 44538 samples generated in d1 upon importing as d2. Note that if <...
slow_learner's user avatar
1 vote
1 answer
162 views

A very basic question about weighted data

I have a dataset in the form {{A1,B1,C1,...},{A2,B2,C2,...},...} and the weights in the form {w1,w2,w3,...} Having this ...
John Taylor's user avatar
  • 5,963
1 vote
0 answers
67 views

How to generate random points with weight distribution and specific criteria? [duplicate]

Consider some function $f(E_{1},E_{2})$, say $$ \tag 1 f(E_{1},E_{2}) = \exp[-E_{1}^{3}+E_{2}^{2}] $$ I want to generate random $n$ points $E_{1}$, $E_{2}$ using this function as weights, with an ...
John Taylor's user avatar
  • 5,963
2 votes
1 answer
61 views

Are there any issues/best practices/suggestions when working with a DataDistribution instead of a distribution?

Suppose there is a random variable $X$ that can take on values $-1,0,1$, with probabilities $P(X=1)=P(X=-1)=.25$ and $P(X=0)=.5$. How can I work with such a random variable in mathematica? (Find the ...
user106860's user avatar
3 votes
1 answer
194 views

How to generate random variate in custom domain for a distribution?

I have a distribution defined in a particular domain of the variable but now I want to generate a random variable not in the entire domain but only in a subset of the domain. Here is what I'm trying ...
user avatar
1 vote
1 answer
70 views

distribution implement for RandomVariate

I have a scalar function of two random matrices of dimension $n$ which are in the Gaussian Unitary Ensemble $$f(x,y) \in \mathbb R, \quad x^{\dagger}=x \: \operatorname{and} \: y^{\dagger} = y, \:\...
Shannon Liu's user avatar
4 votes
2 answers
190 views

Maximum of all distances between any pairs of vertices of a random triangle

Given a set $S_n$ of $n$ points selected uniformly at random in a $d$-ball, I want to estimate the average length of the longest side of a triangle having as vertices any three distinct points of $S_n$...
Penelope Benenati's user avatar
-1 votes
1 answer
105 views

Can the WishartMatrixDistribution command be used for generating random density matrices?

I am interested in generating random members of two classes of $n \times n$ positive-definite matrices $A$ and $B$--the former symmetric in nature, the latter, Hermitian. The standard (Ginibre-matrix-...
Paul B. Slater's user avatar
7 votes
1 answer
393 views

How to distribute points on a Sphere[] cap from a normal distribution?

I was wondering if one could distribute points on a "cap" of a sphere, following a normal distribution of the points instead of a uniform distribution. This normal could be centered at the ...
TumbiSapichu's user avatar
  • 1,643
6 votes
1 answer
584 views

RandomVariate cannot sample from a custom multivariate ProbabilityDistribution

Let us try to define 2D distribution through PDF: ...
Konstantin's user avatar
1 vote
1 answer
38 views

Can I sample from a distribution whose parameters depend on the current iteration?

Let's say I want to sample from 100 Beta distributions, and in each successive one, the first parameter increases by 1. So given a current iteration number n, I ...
rarelyNecessary's user avatar
0 votes
1 answer
183 views

Sampling two integer lists of given sizes from a distribution that have equal sums

(This question emerged from discussions in this post.) Context and code sample: I am trying to figure out if there is a way to generate two $a$ and $b,$ comprised of $n_a$ and $n_b$ integers which ...
user avatar
2 votes
1 answer
103 views

Random Number Generation using LogNormalDistribution

I have a problem that I can't seem to figure out on my own due to limited knowledge of mathematics, and I was hoping I could seek help from the community. I would like to use ...
e.doroskevic's user avatar
  • 5,989
3 votes
1 answer
253 views

Generate a uniform distribution over an $n$-simplex employing quasi-random low-discrepancy points

This post is intended in a similar direction to an earlier one Can I use Compile to speed up InverseCDF? . I now wish to generate uniform points in an $n$-simplex (specifically $n=8$), making use of ...
Paul B. Slater's user avatar
2 votes
1 answer
372 views

RandomReal in combination with NormalDistribution [closed]

I am normally not working with Mathematica, but I have to understand a code written in i! Can some body say what the arguments and parameters of code below say? ...
Seda's user avatar
  • 23
21 votes
5 answers
1k views

Sisyphus Random Walk

A Sisyphus Random Walk evolves as follows: With probability (r) you advance the position of the walker by +1. With probability (1-r) the walker resets at x0 = 0. To simulate the probability of reset ...
smallscot's user avatar
  • 675
7 votes
5 answers
1k views

Survival Probability for Random Walks

The Survival Probability for a walker starting at the origin is defined as the probability that the walker stays positive through n steps. Thanks to the Sparre-Andersen Theorem I know this PDF is ...
smallscot's user avatar
  • 675
1 vote
2 answers
195 views

Sampling data from numerical values of density distribution of nucleons

How could i sample my data which follows distribution if i have only numerical values of density distribution as an example data attached as in picture I tried but do not know how to do it. The data:...
user43830's user avatar
  • 101
2 votes
1 answer
86 views

Drawing random numbers from TransformedDistribution

Suppose I have created the following TransformedDistribution: ...
user120911's user avatar
  • 2,705
2 votes
1 answer
151 views

Random points from an image using a BernoulliDistribution

I am a Mathematica newbie. I need to sample random points from an image which I have stored in a variable img as: ...
mathematicaNewbie's user avatar
0 votes
1 answer
173 views

Negative values with RandomVariate

I am using the following code to generate some random number from a custom distribution: ...
mattiav27's user avatar
  • 6,837
4 votes
3 answers
876 views

Construct Distribution Histogram From Random Variable

Given a Beta Random Variable $X$ with parameters $\alpha, \beta$ and a positive constant $n$, suppose I am interested in the distribution of: $$Y:=\lfloor nX\rfloor$$ Suppose I want a histogram ...
EllipticalInitial's user avatar
4 votes
2 answers
173 views

Optimize RandomVariate for a $1/x^4$ distribution

I'm working with the following code, where I define a probability distribution proportional to $1/x^4$. ...
Jolyon's user avatar
  • 317
7 votes
2 answers
2k views

Can this code be changed to run faster?

I've worked for several days trying to get this code to run faster. The imported data is 15MB. ...
Michael B. Heaney's user avatar
5 votes
1 answer
79 views

Random normalised variable generation

I want to generate 8 random variables (in reality to form 4 complex numbers) such that the sum of the 8 variables squared is equal to unity. The aim of generating such numbers is to perform a quantum ...
Landau's user avatar
  • 51
3 votes
1 answer
267 views

Generating the cumulative distribution function (CDF) of a tuple made by RandomFunction

I use the RandomFunction to generate a continuous random function (trying to model a rough surface): ...
Foad's user avatar
  • 615
3 votes
2 answers
664 views

Distribution of Function of Random Sum of Random Variables

Let $ S = \sum_{i=1}^n X_i$ where: Each $X_i$ is independently 3 or 9 (with equal probability), and The sample size $n$ is itself an independent random variable where $N \sim \text{NegativeBinomial}(...
EllipticalInitial's user avatar
3 votes
1 answer
827 views

Simulate random sample from defined probability density function

Suppose I define a function in mathematica that has all of the properties of a valid probability density function. Would it be possible to have Mathematica simulate a random sample of a given size of ...
EllipticalInitial's user avatar
3 votes
3 answers
147 views

SkewNormalDistribution with a mean value

Since it got incredibly good answers the last time i posted a question, i try it again! ;-) I programmed a chemical/physical simulation in mathematica, where i can use residence time distribution as ...
blackbow's user avatar
1 vote
1 answer
246 views

Modeling Dependent Joint Distribution

I'm trying to model the joint pdf of (X,Y) from example 4.5.8 of the text Statistical Inference 2nd Edition, Casella, Berger (pg 199 of the pdf). Essentially, X ~ Uniform[0,1] Z ~ Unfiorm[0,1/10] Y ...
TensorFlow's user avatar
3 votes
1 answer
475 views

First passage time distribution in mathematica

I'm trying to calculate first passage time distribution for some processes in Mathematica. First I tried to calculate this for Wiener process with zero drift and $\sigma = 1$ and the absorbing ...
Msdos4's user avatar
  • 33
10 votes
4 answers
845 views

Uniform distribution on z = 1 − √( x ^2 + y ^2) , z ≥ 0 [duplicate]

Let $S$ belong to ${\rm I\!R^3}$, $z = 1 − \sqrt{x^2 + y^2}$ , $z ≥ 0$. I need to write a program that generates a random point on $S$ with uniform distribution. I've tried to use ...
Freddy's user avatar
  • 101
1 vote
1 answer
93 views

How to generate number of points in a m/m/c/c process with Poisson arrival and exponential service time?

I am considering the Earling-B or m/m/c/c process. Let the request arrival rate follows Poisson Process with average rate, $\lambda$ Let the service time follows Exponential Distribution, i.e., $\...
George Farnandez's user avatar
8 votes
1 answer
898 views

How to implement Monte Carlo Importance Sample in 2D or in N dimensions?

So far i have managed to implement the Crude Monte Carlo (CMC) and the Importance Sample Monte Carlo (ISMC) for unidimensional problems. Consider the function ...
Stratus's user avatar
  • 2,964
0 votes
1 answer
80 views

Evaluating expression involving a family of probability distributions

I'm trying to use Mathematica to solve a problem involving any continuous probability distribution $F(t)$ such that: $$\begin{align*} F(t)&=0, \; t\leq0\\ F(t)&=1, \; t\geq1 \end{align*}$$ ...
Houston Mooncat's user avatar
1 vote
1 answer
147 views

RandomVariate from Multiplying distributions

Mathematica's RandomVariate works fine with the KernelMixtureDistribution[] function, but it doesn't seem to work if you wish to ...
Dr. Ikjyot Singh Kohli's user avatar
0 votes
0 answers
118 views

Generate random numbers for each time-step that are correlated

I want to generate Gaussian distributed random numbers, but i want them to be correlated, e.g $E[\epsilon(t)\epsilon(t')]=C(t-t')$ where $C$ is some function and $E[\cdot]$ denotes the expectation ...
Martin's user avatar
  • 227
3 votes
3 answers
888 views

Produce a probability vector with uniform distribution [duplicate]

A probability vector is a vector $\mathbf{p}=(p_1,p_2,\ldots,p_n)$ with the following properties: $\sum_{i=1}^{n}p_i=1$ $p_i\geq 0$ Assume that the set of all possible probability vectors is $\...
Math_Y's user avatar
  • 131
4 votes
3 answers
274 views

RandomVariate of ProbabilityDistribution returns values outside the support of a CDF (non-symmetric PDF)

From this post (95069) I can see that this question has been been given a workaround for symmetric PDFs and that the bug was eventually addressed. I checked and the fix is still in place for my ...
Edmund's user avatar
  • 43.2k
1 vote
0 answers
101 views

Mathematica cannot generate the random variables for a given Probability Distribution

I need to generate a large number of random variables from the distribution generated by the following code. Distribution is given by DistributionF. The code is ...
George Harnandez's user avatar