# Tag Info

### How to sample points randomly below a curve?

There is no need in filtering out random points in a rectangle that don't fall in the prescribed region. The sampling within a region can be done directly with ...
• 24k
Accepted

### How to sample points randomly below a curve?

As noted in my comment, one approach is as follows. First, generate thousands of pairs of random numbers in the range {0, 2 π}, ...
• 61.8k

### How to sample points randomly below a curve?

More of a first principles approach, use the function as a PDF to generate random x data, then for each ...
• 39k

### How to sample points randomly below a curve?

In case where only the plot is given: plot = Plot[1/π Cos[θ]^2, {θ, 0, 2 π}, Filling -> Bottom] ...
• 137k

### How to implement the sample-point process like the built-ins of Mathematica?

Being highly astonished about all the very interesting answers, I only want to add an approach using NMinimize. Not very fast, but straightforward. The idea behind ...
• 54.6k
Accepted

### Sample over a matrix

Create a function that does this for exactly one entry. Then use this function on all your entries: ...
• 113k
Accepted

### Random sample of big big numbers

You can use Span to avoid the blowup from Range: ...

### Sample over a matrix

Also f0 = Extract[#, {{1}, {2}, {RandomInteger[{3, 5}]}}] &; f0 /@ mat {{1, 1, 3}, {2, 2, 3}, {3, 3, 2}, {4, 4, 7}, {5, 5, 6}, {6, 6, 7}, {7, 7, 4},...
• 398k

### Why does plot not show where Piecewise function is not zero?

Try Plot[f[x], {x, 0, 1.0001}, PlotPoints -> {Automatic, { 1}}] Don't know why this workaround only works for extended plotrange.
• 54.6k
Accepted

### Plot, sampling, and why it does not display for some ranges

Your plots aren't empty: they have a line along the x axis. Plot uses PlotPoints -> 50 by default, and since you go from -30 ...
• 20.8k
Accepted

### Finding the periodicity (or wavelength) in approximately periodic data irregularly sampled

This is something one can tackle using an irregular periodogram, and that happens to be available in the Wolfram Function Repository. Grab the data and separate into times and values. ...
• 59.3k

### Plot, sampling, and why it does not display for some ranges

Brett's answer explains the why. To force sampling at specified points you can use an undocumented form of PlotPoints (see this answer by Ullrich Neumann) : ...
• 398k
Accepted

### Why does plot not show where Piecewise function is not zero?

You can use ParametricPlot to show the jumps at the boundaries of the domain without having to extend the domain. If jumps occur only at the boundaries using <...
• 398k

### Sample over a matrix

Here's a faster extractor using a single Extract and single RandomInteger call, although still with a minimally expensive ...
• 46.9k
Accepted

### Sampling Implicit functions

The sampling is done by ContourPlot. To extract the data: ...
• 146k
Accepted

### Sample the data with equal step size

Also TimeSeriesResample[data, {Range[1, data[[-1, 1]], τ]}] {{1, 0}, {2, 0}, {3, 3}, {4, 10}, {5, 17}, {6, 27}, {7, 43}, {8, 63}}
• 398k

### How to generate a matrix with certain conditions

Binary random variables are often modeled using the BernoulliDistribution. You can use the function RandomVariate to get a ...
• 69.2k
Accepted

### Is there a way to generate a data-driven Monte Carlo sample from a histogram?

You may do this using "SmoothKernelDistribution". Here is a simple example. We first create some data from a Normal Distribution: ...
• 53.1k

### Is there a way to generate a data-driven Monte Carlo sample from a histogram?

This is precisely what RandomChoice does: choosing numbers according to weights. For example, if your histogram is ...
• 48.3k

### Finding the periodicity (or wavelength) in approximately periodic data irregularly sampled

Maybe a nonlinear fit would work for you, but it needs a good starting point to converge: ...
• 48.3k
Accepted

### How to compile the following code (sampling from a distribution)?

Is UniformDistribution compilable? (Or maybe RandomReal?) If so, then making use of the fact that a ...
• 41.9k

### How to generate a matrix with certain conditions

Since all the simple answers have been given, here is a SparseArray[] solution that may be useful if you want to generate large matrices without storing unneeded ...

### How to generate a matrix with certain conditions

You can use weight option in RandomChoice ...
• 10.9k

### Random sample of big big numbers

You could experiment a bit with the following function ...

...
• 398k

### Sampling Implicit functions

How to sample points on f[x, y] == c without explicitly solving for y? In old versions of Mathematica, Nasser's method is what ...

### Sampling Implicit functions

For random sampling, one can use regions and RandomPoint: ...
• 238k

### Finding the periodicity (or wavelength) in approximately periodic data irregularly sampled

Try using Periodogram. See for more HERE. In short on an example, let's take temperature data - about 2 decades, sampling monthly: ...
• 73.4k
Accepted

...
• 160k
Accepted

### Pick random value based on list of probabilities

SeedRandom[1]; RandomChoice[WeightedData @@ Transpose[probabilities], 5] {12500, 4500, 12500, 5500, 5500} Alternatively, <...
• 398k

Only top scored, non community-wiki answers of a minimum length are eligible