I realize that one uses set.seed() in R for pseudo-random number generation. I also realize that using the same number, like set.seed(123) insures you can reproduce results.   But what I don't get is what do the values themselves mean. I am playing with several functions, and some use set.seed(1) or set.seed(300) or set.seed(12345). What does that number mean (if anything)- and when should I use a different one.   Example, in a book I am working through- they use set.seed(12345) when creating a training set for decision trees. Then in another chapter, they are using set.seed(300) for creating a Random Forest.  Just don't get the number.
124173
I tried some usual google search etc. but most of the answers I find are either somewhat ambiguous or language/library specific such as Python or C++ stdlib.h etc. I am looking for a language agnostic, mathematical answer, not the specifics of a library.   As an example, many say that the seed is a starting point of random number generator and the same seed always produces the same random number. What does it mean? Does it mean the output number is a deterministic function of a specific seed, and the randomness comes from the value of the seed? But if that is the case, then by supplying the seed, are not we, the programmers, creating the randomness instead of letting the machine do it?  Also, what does a starting point mean in this context? Is this a non-rigorous way of saying an element $x\in\mathfrak{X}$ of the domain of a map $f:\mathfrak{X}\rightarrow\mathfrak{Y}$? Or am I getting something wrong?
118969
Consider the following problem. I am looking for the maximum number of different sets that we can generate by one set $B \subseteq \mathbb{R}$ by taking a finite amount of closures and interiors. For example $\{0\}$ generates the sets $\{0\}$ and $\emptyset$. At first I thought the answer was 3 (we can only generate B, the closure of B and the interior of B) because I thought $\overline{B^\circ}=\overline{B}$ and $\overline{B}^\circ=B^\circ$. But then I looked at the example $B=\mathbb{Q}$ and found that $\overline{\mathbb{Q}}^\circ=\mathbb{R}^\circ=\mathbb{R}\neq\emptyset=\mathbb{Q}^\circ$.  This is not what I would expect and I clearly need another method to find that maximum.
88523
I've already, searched and read, many answers about this issue for 3 days, but couldn't get a clear answer on how to do this.  this will be a little long, be patient please.  First of all, I am trying to make a simple lottery app. I hope everyone of you know about the 6/49 lottery thing.  Well, according to game, first, for a week customers play lottery (lotteryTBL). Then 6 numbers between 1-49 are selected as lucky numbers (resultsTBL).  What I want to do is updating lotteryTBL after a new result row is inserted into resultsTBL.  Structure of lotteryTBL:  ID    num1  num2  num3  num4  num5  num6     draw_date      howmanyknew  1       5    6     8    15      18    25     08-21-2015         0 2       7    15    18   30      40    45     08-21-2015         0   Structure of resultsTBL:  ID    num1  num2  num3  num4  num5  num6     draw_date   1      15    18    35    38    40    47     08-21-2015    Now, here is the pseudocode of what i want:  after insert a new row into resultsTBL    total &lt;- 0    for each row in the lotteryTBL where lotteryTBL.draw_date = resultsTBL.draw_date        total &lt;- calculate how many of them are the same with the resultsTBL's row.    update lotteryTBL set howmanyknew = total where "some condition"   First, I tried to do it with trigger, some said "it is dynamic sql, you cannot use trigger", some said "use stored procedure". And I did it too. But, they never worked.  Anyway, Can someone type a good pseudocode for this? which method do I have to use? what is the logic here?
112911
Context: I'm trying to understand the use of variational autoencoders as generators. My understanding:   During training, for an input point $x_i$ we want to learn latent $\mu_i$ and $\sigma_i$ and then sample $z_i \sim N(\mu_i, \sigma_i)$ and feed it to the decoder to get a reconstruction $\hat{x}_i = \text{decode}(z_i)$. But we can't do back propagation with sampling operator, so instead we reparametrize and use $z_i = \mu_i + \sigma_i \epsilon$ where $\epsilon \sim N(0, 1)$. Our reconstruction becomes $\hat{x}_i = \text{decode}(\mu_i + \sigma_i \epsilon)$.   However when we're done with training and ready to use it as generator, we sample $z \sim N(0, 1)$ and feed it to decoder: $x_{sample} = \text{decode}(z)$ .  The part that confuse me is that during training, the decode operation was done using $\mu_i + \sigma_i \epsilon$ which to my understanding this is using $N(\mu_i, \sigma_i)$ with different $\mu_i$ and $\sigma_i$ for each training example. However during the generation time, the decode operation is done (effectively) on $\epsilon$ alone from $N(0, 1)$. Why are we setting $\mu = 0$ and $\sigma = 1$ during generation (i.e. using $z = 0 + 1 \cdot \epsilon$)?
9526
I need to generate random numbers following Normal distribution within the interval $(a,b)$. (I am working in R.)  I know the function rnorm(n,mean,sd) will generate random numbers following normal distribution,but how to set the interval limits within that? Is there any particular R functions available for that?
95699
I confirmed on  thread that there are as many as even natural numbers as there are natural numbers.   Question : Suppose I have selected a number $n \in \mathbb N$; what is the probability that $n$ is even?  My Thought : $\text{Probability} = \dfrac{\text{n(E)}}{\text{n(S)}}$ Here $\text{n(S)}$ is the set of all natural numbers i.e. $\mathbb N$, and $\text{n(E)}$ is set of all even natural numbers. Since it is proved that number of elements is the set $\mathbb N$ is exactly the same as the number of elements in the set of natural numbers (it’s very easy to put the set of natural numbers, $\Bbb N=\{0,1,2,3,\dots\}$, into one-to-one correspondence with the set $\text{E}=\{0,2,4,6,\dots\}$ of even natural numbers; the map $\Bbb N\to \text{E}:n\mapsto 2n$ is clearly a bijection.) ; Thus, Probability $= \boxed 1$ I know this is definitely wrong.Probability must be $0.5$. But where am I wrong? Can anyone explain ? Thanks!
101154
Suppose I have a discrete set of (finite) data (values are only positive integers) (which always remains discrete whenever the observation/survey is taken), divided into some identical categories . Now, I want to calculate the mean values of some random variable for each category, hence getting a sequence of mean values. Considering mean as a random variable (let's call it $M$), it's taking decimal values also (obviously possible). But I am not sure if $M$ is a discrete or a continuous random variable.   My intuition suggest me that it should be discrete. Since, my original data from which I calculated the sets of mean is discrete so the mean can take finitely many values which I suppose is not the case with a continuous random variable where the mean can take infinitely many values within an interval. So is my intuition right or wrong?  Is it true that a discrete random variable takes finitely many values and continuous R.V. can take infinitely many possible values?
36924
Is there a reasonable statistic test one can do to standard random number generators (say, one of those that come built in in Python libs) which shows they are not really random?  (By reasonable I mean to exclude silly things like «generate a looong list and see that it is periodic»)  Later: Notice I am looking for a test that fails on standard generators.
22767
Is it possible to seed the random number generator () in JavaScript?
47209
I'm trying to model a Roulette game where if you bet on red (out of red(18/37), black(18/37), green(1/37)) and if you the ball lands on red you win 1 dollar and if it doesn't you lose $1. So in this case, is it a binomial distribution? Since there are only 2 outcomes from the gamblers perspective, red or not red. If thats the case are these 2 R functions the same?  set.seed(3) sample(c(0,1),100,replace=T,prob=c(19/37,18/37))     rbinom(n = 100, size = 1, prob = 18/37)
82315
What do we mean when we say &quot;Let $x$ be an element of the set $\mathbb{R}$&quot;?  Does $x$ represents only a single  element of set $\mathbb{R}$? or does $x$ represent all the element of set $\mathbb{R}$ simultaneously at the same time? People say that if $x\in\mathbb{R}$ then $x$ is any real number; that means $x$ represents all real numbers. But if $x$ is any real number then let's say $x=1$; so $x$ is one, then how it can represent all real numbers? Please help me I am very confused.
372
What is the difference between the search() and match() functions in the ?  I've read the  (), but I never seem to remember it.  I keep having to look it up and re-learn it.  I'm hoping that someone will answer it clearly with examples so that (perhaps) it will stick in my head.  Or at least I'll have a better place to return with my question and it will take less time to re-learn it.
64845
In how many ways can we choose $r$ numbers from $\{1,2,3,...,n\}$,   In a way where we have no consecutive numbers in the set? (like $1,2$)
19656
I've noticed that when building random forest regression models, at least in R, the predicted value never exceeds the maximum value of the target variable seen in the training data. As an example, see the code below. I'm building a regression model to predict mpg based on the mtcars data. I build OLS and random forest models, and use them to predict mpg for a hypothetical car that should have very good fuel economy. The OLS predicts a high mpg, as expected, but random forest does not. I've noticed this in more complex models too. Why is this?   &gt; library(datasets) &gt; library(randomForest) &gt;  &gt; data(mtcars) &gt; max(mtcars$mpg) [1] 33.9 &gt;  &gt; set.seed(2) &gt; fit1 &lt;- lm(mpg~., data=mtcars) #OLS fit &gt; fit2 &lt;- randomForest(mpg~., data=mtcars) #random forest fit &gt;  &gt; #Hypothetical car that should have very high mpg &gt; hypCar &lt;- data.frame(cyl=4, disp=50, hp=40, drat=5.5, wt=1, qsec=24, vs=1, am=1, gear=4, carb=1) &gt;  &gt; predict(fit1, hypCar) #OLS predicts higher mpg than max(mtcars$mpg)       1  37.2441  &gt; predict(fit2, hypCar) #RF does not predict higher mpg than max(mtcars$mpg)        1  30.78899
90809
Does anyone know if there is a good equivalent to Java's Set collection in C#? I know that you can somewhat mimic a set using a Dictionary or a HashTable by populating but ignoring the values, but that's not a very elegant way.
99775
Suppose I have a set of 100 integers. I randomly choose 10 of those, make a note of which ones I selected, and repeat the process. What is the expected number of times this process must be repeated before I see all 100 integers?  I'm also greatly interested in how this is calculated as I'm trying to increase the expected number of times this process is repeated by changing the set sizes.
37401
If I run the R code below, it will generate two independent vectors then test them to see if they are related in some way (i.e. p-value &lt; 0.05).  If I repeat this 1,000 times, then 50 of these (5%) will have a false positive, with a p-value &lt; 0.05. This is a type 1 error.  If we increase sampleSize to 1000, or even 100,000, the results are the same (5% false positives).  I am struggling to understand this, as I would have thought that if we collected enough samples, the chance of a false positive would drop towards 0 (just like correlation).  So, I guess my question is: "How is it possible that the number of false positives, based on p-values generated from comparing two independent datasets, be independent of sample size?".  # R code to demonstrate that with a large dataset, we can still  # get significant p-values, purely by chance.  # Change this to 1000, and we still get the same number of false positives (50, or 5%). sampleSize = 20  cat("Sample size:",sampleSize,"\n")  set.seed(1010093) n=1000 pValues &lt;- rep(NA,n) for(i in 1:n){     y &lt;- rnorm(sampleSize)     x &lt;- rnorm(sampleSize)     pValues[i] &lt;- summary(lm(y ~ x))$coeff[2,4] } # Controls false positive rate fp = sum(pValues &lt; 0.05) cat("Out of ",n," tests, ",fp," had a p-value &lt; 0.05, purely by by chance.\n",sep="")  ----output---- Running "true positives - none.R" ... Sample size: 1000  Out of 1000 tests, 52 had a p-value &lt; 0.05, purely by by chance.