# All Questions

Tagged with
22 questions
Filter by
Sorted by
Tagged with
1k views

### Get quantile function of dynamic mixture model

I have a dynamic mixture distribution fitted to my risk data (i.e., I have all parameters) of Weibull and Generalized Pareto, with a Cauchy CDF mixing function, that can be written as: \begin{align} ...
33k views

### Generating random samples from a custom distribution

I am trying to generate random samples from a custom pdf using R. My pdf is: $$f_{X}(x) = \frac{3}{2} (1-x^2), 0 \le x \le 1$$ I generated uniform samples and then tried to transform it to my custom ...
8k views

### How to draw random samples from a non-parametric estimated distribution?

I have a sample of 100 points which are continuous and one-dimensional. I estimated its non-parametric density using kernel methods. How can I draw random samples from this estimated distribution?
621 views

### Estimate the size of a population being sampled by the number of repeat observations

Say I have a population of 50 million unique things, and I take 10 million samples (with replacement)... The first graph is I've attached shows how many times I sample the same "thing", which is ...
1k views

### How to generate 2 correlated Beta random variables

I was wondering if it might be possible to generate 2 correlated $Beta$ random variables? In other words, I want to generate two Beta random variables which can be said to have come from two Beta ...
13k views

### How to resample in R without repeating permutations?

In R, if I set.seed(), and then use the sample function to randomize a list, can I guarantee I won't generate the same permutation? ie... ...
744 views

### How to simulate effectiveness of treatment in R?

Let's say I want to write a simulation for the table below to decide if Xylitol treatment and ear infections are independent. How would I go about doing this?
751 views

### Sampling from copula given a particular value of marginal

I am working in the bivariate case with copulas as follows: I have two marginal Gamma distributions $f_1=Ga(\alpha_1, 1)$ and $f_2=Ga(\alpha_2, 1)$ that are bound by a copula Frank copula $C$, with ...
2k views

### How to exact prediction from over sampled data(Undoing oversampling)?

We are oversampling the data to use in logistic regression. Aim is to predict CTR(click probability) which is rare event scenario. I have predicted the probabilities of click but CTR results are ...
4k views

### Using Uniform Distribution to Generate Correlated Random Samples in R

[On recent questions I was looking into generating random vectors in R, and I wanted to share that "research" as an independent Q&A on a specific point.] Generating random data with correlation ...
2k views

The out-of-context short version Let $y$ be a random variable with CDF $$F(\cdot) \equiv \cases{\theta & y = 0 \\ \theta + (1-\theta) \times \text{CDF}_{\text{log-normal}}(\cdot; \mu, \sigma) &... 2answers 6k views ### Sample from distribution given by histogram Given a histogram obtained using given data points, how do I randomly sample from the distribution predicted by the histogram? Any conceptual comment / R code would be welcome. 3answers 291 views ### How to sample from a distribution so that mean of samples equals expected value? Given a random variable X, how do I have obtain N random variates of X so that the mean value of my samples equals the expected value of X? E.g. let X have uniform distribution on the ... 2answers 8k views ### How do I sample without replacement using a sampling-with-replacement function? I vaguely recall from grad school that the following is a valid approach to do a weighted sampling without replacement: Start with an initially empty "sampled set". Draw a (single) weighted sample ... 1answer 6k views ### Leave-one-subject-out cross validation in Caret Hi Dear Colleagues, I wonder how to correctly setup a leave-one-subject-out cross validation (LOSO) for train() function in caret. Here is my example code: ... 1answer 74 views ### Is there a more efficient method for creating a probability distribution? I have written a short function in R to estimate the expected number of mutations that will be observed in a set of DNA sequences. The parameters are the mutation rate (x), the length of the DNA ... 1answer 817 views ### Absent categorical data levels in Bootstrap samples I have a huge dataset (n around five million, p around three thousand) for a classification problem, where my interest is predictive class probabilities for test data, not the target. I shall be ... 1answer 184 views ### Why do two equivalent approaches to selecting numbers that sum to 100 produce different results This question is inspired by two seemingly equivalent attempts to solve a question asked yesterday: In R, how to sample from the output of combn(a,b) if the "a choose b" is too large? ... 1answer 350 views ### Sampling from under/over-dispersed count data in R I am currently working a some datasets with count data in R, in which the response is the number of activities of a given type that were performed in one day by a population. For each type, I build ... 3answers 2k views ### In R, how to sample from the output of combn(a,b) if the “a choose b” is too large? I would like to sample 1 million vectors from the set of vectors$$\mathbf{v} = \{v_1,v_2,...,v_n \}  subject to $\sum_{i=1}^n v_i = 1$ $\forall i: v_i \ge 0$ each $v_i$ has at most 2 decimal ...
I'm trying to implement an algorithm that estimates time-homogeneous Markov chain with continuous state space. The probability of transition from state $i$ to state $i+1$ has continuous conditional ...