Questions tagged [sampling]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
5 votes
4 answers
352 views

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

I have irregularly sampled data that looks as in the picture. Is there a function in Mathematica that allows me to find an approximate or average period or wavelength? I know beforehand that the data ...
user avatar
  • 567
0 votes
0 answers
28 views

How to convert the range of variable to one determined value through random sampling in a list?

Suppose I have the following list of list ...
user avatar
0 votes
1 answer
72 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 <...
user avatar
3 votes
2 answers
157 views

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

I have a vector with 50 elements. These are values of a random variable. I have represented the data as Histogram[RandomVariable1Histogram]. However, I need to ...
user avatar
4 votes
1 answer
129 views

Reverse engineer visualizations to compactly extract underlying data

TL;DR How to implement in mathematica a tool such as WebPlotDigitizer by Ankit Rohatgi which would allow us to trace automatically curves from either (randomly ordered) data or imported images. ...
user avatar
  • 21.7k
4 votes
2 answers
97 views

Smart under-sampling of a large list of data points

I have dielectric functions of materials as lists of value pairs {{x1, y1}, {x2, y2}, ...} and unfortunately some of them are quite long, which is a bother in ...
user avatar
1 vote
0 answers
39 views

putting condition on do loop

...
user avatar
  • 157
1 vote
1 answer
35 views

Select a subsequence of a sequence according to tosses of a biased coin

I have a sequence, from which I would like to select a subsequence, each term of the original sequence being included in the subsequence with probability $p$, independently of the other terms. That is,...
user avatar
  • 1,385
1 vote
2 answers
140 views

Evaluate function at "good" points used by Plot in numerical problems

Plot function with option Mesh->All shows how mathematica evaluates function to make it most optimal for plotting. I'd like to evaluate some physical function in ...
user avatar
0 votes
2 answers
63 views

How to get a list of exponentially distributed points sampled in a range

I want to get 256 points exponentially sampled in a range, and then get its histogram. If I plot PDF, I get the following: ...
user avatar
  • 157
2 votes
4 answers
236 views

Sampling Implicit functions

Consider an implicit function like f ...
user avatar
  • 902
2 votes
1 answer
127 views

How to extract colors from ColorsNear?

Is there any way to get a discrete list of samples from the ColorsNear function? I have tried ...
user avatar
  • 465
0 votes
1 answer
134 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
1 vote
2 answers
77 views

Sampling an inequality over multi-dimensional space

Let's say I have two functions $f(x,y,z), g(x,y,z)$. I would like to know the probability that $f(x,y,z) < g(x,y,z)$ over some defined, numerical ranges of $x, y, z$. Any thoughts on how to do it ...
user avatar
8 votes
2 answers
251 views

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

The following gives an empty plot on V12 under Windows 10: ...
user avatar
  • 110k
5 votes
2 answers
422 views

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

From my user point view this looks like bug. But I am not an expert. f[x_?NumericQ]:=Piecewise[{{1,x==1},{0,True}}]; Plot[f[x],{x,0,1}] Does not show ...
user avatar
  • 110k
1 vote
1 answer
146 views

Random sampling of a discrete distribution in NetGraph

Within a NetGraph I would like to use the output of a softmax layer, interpreted as a probability distribution, to sample a "next token". Since this is done inside an RNN structure, I cannot do this ...
user avatar
1 vote
2 answers
276 views

Multiple unique random samples?

I'm trying to produce $n$ random samples from a list, but not all samples, and I'd like the samples to not repeat in the same execution of the command. If I'm not mistaken, something like ...
user avatar
2 votes
4 answers
322 views

How to generate a matrix with certain conditions

I want to generate a $n \times n$ matrix. I want the diagonal entries to be all 0 I want a random choice of matrix elements with 0 or 1. The probability of having a 1 as a matrix element is $1/m$ and ...
user avatar
  • 21
0 votes
1 answer
141 views

How do I extract data points from an audio plot at a constant spaced time interval?

AudioPlot[Audio[File["Downloads/1_mp3.wav"]]] data = Cases[AudioPlot[Audio[File["Downloads/1_mp3.wav"]]], Line[x_] :> x, Infinity] This code can extract data ...
user avatar
  • 3
1 vote
2 answers
146 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:...
user avatar
  • 101
0 votes
1 answer
51 views

ProbabilityDistribution fails for square root

I would like to sampling data from a distribution Sqrt[x^2 + y^2]. I used the code as follows: ...
user avatar
0 votes
1 answer
101 views

Speeding up Module

I am working on the Ising 2D model in Mathematica and this is currently my Metropolis sampling function: ...
user avatar
  • 11
4 votes
2 answers
146 views

Filtering data with timestamps

How to apply filter to data that was sampled in certain moments of time? Examples from documentation deal only with uniformly sampled data: ...
user avatar
0 votes
3 answers
97 views

Sample the data with equal step size

I have the data below. I would like to sample with equal step size. For simplicity lets try unit step size. Here is the desired result. Find the first time exceed the unit time step, and take lower ...
user avatar
5 votes
2 answers
236 views

Random sample of big big numbers

Consider the following piece of code: m = 2; n = 6; samplesize = 1000; totalsize = 2^(n^m); numbersample = 2 RandomSample[Range[totalsize/2], samplesize]; With ...
user avatar
  • 558
5 votes
3 answers
382 views

Sample over a matrix

Assume I have a matrix. ...
user avatar
2 votes
1 answer
81 views

Looking for an estimator for non-linear statistics

Goal We sample $n$ individuals with replacement and measure their trait values $x_i$ for all individual $i$. The variable $x$ is bounded [0,1]. Let $\mu$ be the ...
user avatar
  • 1,105
0 votes
0 answers
85 views

Problems with sampling

Let $t\ge 0$ and let $f_{s}(t)$ be the sampled version of $f(t)$. If $$f(t)=\begin{cases}\int_{0}^{t}\exp\left(-\frac{1}{1-s^{2}}\right)\,ds,&|s|<1, \\ 0,&\text{otherwise}.\end{cases}$$ I ...
user avatar
26 votes
4 answers
3k views

How to sample points randomly below a curve? [duplicate]

How can I randomly select 1000 points uniformly from the shaded area below the plotted curve? Plot[1/π Cos[θ]^2, {θ, 0, 2 π}, Filling -> Bottom]
user avatar
5 votes
2 answers
304 views

Generate multiple integer variables with constant sum

I have asked similar question three day ago[The old question]. it was incorrectly marked as duplicated. This time I make this question more general and closer to reality. I want to build a model of N ...
user avatar
  • 594
37 votes
4 answers
2k views

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

Consider this: pts = {{0, 0}, {1, 1}, {2, -1}, {3, 0}, {4, -2}, {5, 1}}; f = BSplineFunction[pts] I can use ParametricPlot to ...
user avatar
  • 435
7 votes
1 answer
335 views

Draw from a given list according to empirical distribution

I have two lists, where each time I have age-income vectors. Given the distribution of age in the first list, I would like to draw a sample with the similar distribution of age from the second list (...
user avatar
  • 651
20 votes
2 answers
2k views

How to obtain adaptive sampling as in Plot function?

Adaptive sampling in Plot function can capture the oscillation of a function with very few points. How can I get a similar sequence of point pairs without using <...
user avatar
  • 2,491
0 votes
1 answer
310 views

Sampling Points Between Two Functions and Plotting Sample Points? (I have partial code) [duplicate]

I want to sample random points between $Cos(x)$ and $Sin(x)$ on $0 \le x\le \frac \pi4$ I was able to do graph the function here in Mathematica. I would like to count, and then plot points between ...
user avatar
  • 191
2 votes
0 answers
1k views

Draw sample functions from Gaussian Process prior [closed]

Previously, I have written implementation codes of Gaussian Process regression in Python and Matlab. However, for better interaction and visualisation, I am currently working on implementation in ...
user avatar
  • 21
2 votes
1 answer
1k views

Latin Hypercube Sampling

I'm looking into Mathematica and I can't find if there is an instruction or a set of them that can perform the Latin Hypercube Sampling, given variable, their ...
user avatar
  • 157
1 vote
0 answers
413 views

Is this the correct method in using bootstrapping to determine a lower confidence bound?

Quite often in industry, due to cost and schedule constraints, decisions must be made on small sample size data. I have 4 cycles-to-failure values resulting from running samples to failure in a ...
user avatar
  • 1,357
54 votes
2 answers
3k views

Adaptive sampling for slow to compute functions in 2D

EDIT: Although I have posted an answer based on my current progress, this in incomplete. Please see the "open issues" section in the answer. Most plotting functions in Mathematica adjust the ...
user avatar
  • 225k