Skip to main content
broken image fixed (click 'rendered output' to see the difference); for more info, see https://gist.github.com/Glorfindel83/9d954d34385d2ac2597bbe864466259f
Source Link

I have two random variables $s\sim \mathcal{N}(\nu,\sigma)$ and $a\sim \mathcal{U}(0,A)$, $0<A<1$, calculate a third r.v. $t=(1-a)/s$ and want to find its distribution $p(t|\nu,\sigma,A)$.

My reasoning is, that for any value of $a$, there is exactly one $s=(1-a)/t$ such that the $(a,s)$ pair will produce $t$ and I will therefore have to integrate over the probabilities for these values:

$$p(t|\nu,\sigma,A) = \int_0^A p_a(x)p_s((1-x)/t)\,\mathrm dx\\$$

which can be expressed as the sum of two error functions.

But already when checking this step numerically, I get a discrepancy between estimated (by sampling) and calculated distribution:

http://i45.tinypic.com/2da0ew5.png

Why do the histogram and the calculated distribution do not match?

This is the code I used:

n=10000000

A=0.7
nu=.7
sigma=.1

# sampling from the target distribution
s=rnorm( n, mean=nu, sd=sigma )
a=runif( n, min=0, max=A )
t=(1-a)/s
hist(t,200, freq=F, xlim=c(0,5), ylim=c(0,2.5))


# plot the analytical result
analytic <- function(t, A, nu, sigma ){
  tmp <- function(x, A, t, nu, sigma){
     return (1/A*dnorm( (1-x)/t, mean=nu, sd=sigma) )
  }
  return( integrate( tmp, 0, A, A=A, t=t, nu=nu, sigma=sigma)$value)
}

x=seq(0,5,by=.01)
y=rep(0,length(x))
for( i in seq(1,length(x)) ){
  y[i]=analytic(x[i], A, nu, sigma)
}
lines( x, y, col="red", type="l")

I have two random variables $s\sim \mathcal{N}(\nu,\sigma)$ and $a\sim \mathcal{U}(0,A)$, $0<A<1$, calculate a third r.v. $t=(1-a)/s$ and want to find its distribution $p(t|\nu,\sigma,A)$.

My reasoning is, that for any value of $a$, there is exactly one $s=(1-a)/t$ such that the $(a,s)$ pair will produce $t$ and I will therefore have to integrate over the probabilities for these values:

$$p(t|\nu,\sigma,A) = \int_0^A p_a(x)p_s((1-x)/t)\,\mathrm dx\\$$

which can be expressed as the sum of two error functions.

But already when checking this step numerically, I get a discrepancy between estimated (by sampling) and calculated distribution:

http://i45.tinypic.com/2da0ew5.png

Why do the histogram and the calculated distribution do not match?

This is the code I used:

n=10000000

A=0.7
nu=.7
sigma=.1

# sampling from the target distribution
s=rnorm( n, mean=nu, sd=sigma )
a=runif( n, min=0, max=A )
t=(1-a)/s
hist(t,200, freq=F, xlim=c(0,5), ylim=c(0,2.5))


# plot the analytical result
analytic <- function(t, A, nu, sigma ){
  tmp <- function(x, A, t, nu, sigma){
     return (1/A*dnorm( (1-x)/t, mean=nu, sd=sigma) )
  }
  return( integrate( tmp, 0, A, A=A, t=t, nu=nu, sigma=sigma)$value)
}

x=seq(0,5,by=.01)
y=rep(0,length(x))
for( i in seq(1,length(x)) ){
  y[i]=analytic(x[i], A, nu, sigma)
}
lines( x, y, col="red", type="l")

I have two random variables $s\sim \mathcal{N}(\nu,\sigma)$ and $a\sim \mathcal{U}(0,A)$, $0<A<1$, calculate a third r.v. $t=(1-a)/s$ and want to find its distribution $p(t|\nu,\sigma,A)$.

My reasoning is, that for any value of $a$, there is exactly one $s=(1-a)/t$ such that the $(a,s)$ pair will produce $t$ and I will therefore have to integrate over the probabilities for these values:

$$p(t|\nu,\sigma,A) = \int_0^A p_a(x)p_s((1-x)/t)\,\mathrm dx\\$$

which can be expressed as the sum of two error functions.

But already when checking this step numerically, I get a discrepancy between estimated (by sampling) and calculated distribution:

Why do the histogram and the calculated distribution do not match?

This is the code I used:

n=10000000

A=0.7
nu=.7
sigma=.1

# sampling from the target distribution
s=rnorm( n, mean=nu, sd=sigma )
a=runif( n, min=0, max=A )
t=(1-a)/s
hist(t,200, freq=F, xlim=c(0,5), ylim=c(0,2.5))


# plot the analytical result
analytic <- function(t, A, nu, sigma ){
  tmp <- function(x, A, t, nu, sigma){
     return (1/A*dnorm( (1-x)/t, mean=nu, sd=sigma) )
  }
  return( integrate( tmp, 0, A, A=A, t=t, nu=nu, sigma=sigma)$value)
}

x=seq(0,5,by=.01)
y=rep(0,length(x))
for( i in seq(1,length(x)) ){
  y[i]=analytic(x[i], A, nu, sigma)
}
lines( x, y, col="red", type="l")
added 8 characters in body; edited title
Source Link
cardinal
  • 27.3k
  • 8
  • 105
  • 140

Dividing a uniform by a normal r.v.random variable: what'sWhat's the distribution?

I have two random variables $s\sim \mathcal{N}(\nu,\sigma)$ and $a\sim \mathcal{U}(0,A)$, $0<A<1$, calculate a third r.v. $t=(1-a)/s$ and want to find its distribution $p(t|\nu,\sigma,A)$.

My reasoning is, that for any value of $a$, there is exactly one $s=(1-a)/t$ such that the $(a,s)$ pair will produce $t$ and I will therefore have to integrate over the probabilities for these values:

$$p(t|\nu,\sigma,A) = \int_0^A p_a(x)p_s((1-x)/t)\,dx\\$$$$p(t|\nu,\sigma,A) = \int_0^A p_a(x)p_s((1-x)/t)\,\mathrm dx\\$$

which can be expressed as the sum of two error functions.

But already when checking this step numerically, I get a discrepancy between estimated (by sampling) and calculated distribution:

http://i45.tinypic.com/2da0ew5.png

Why do the histogram and the calculated distribution do not match?

This is the code I used:

n=10000000

A=0.7
nu=.7
sigma=.1

# sampling from the target distribution
s=rnorm( n, mean=nu, sd=sigma )
a=runif( n, min=0, max=A )
t=(1-a)/s
hist(t,200, freq=F, xlim=c(0,5), ylim=c(0,2.5))


# plot the analytical result
analytic <- function(t, A, nu, sigma ){
  tmp <- function(x, A, t, nu, sigma){
     return (1/A*dnorm( (1-x)/t, mean=nu, sd=sigma) )
  }
  return( integrate( tmp, 0, A, A=A, t=t, nu=nu, sigma=sigma)$value)
}

x=seq(0,5,by=.01)
y=rep(0,length(x))
for( i in seq(1,length(x)) ){
  y[i]=analytic(x[i], A, nu, sigma)
}
lines( x, y, col="red", type="l")

Dividing a uniform by a normal r.v.: what's the distribution?

I have two random variables $s\sim \mathcal{N}(\nu,\sigma)$ and $a\sim \mathcal{U}(0,A)$, $0<A<1$, calculate a third r.v. $t=(1-a)/s$ and want to find its distribution $p(t|\nu,\sigma,A)$.

My reasoning is, that for any value of $a$, there is exactly one $s=(1-a)/t$ such that the $(a,s)$ pair will produce $t$ and I will therefore have to integrate over the probabilities for these values:

$$p(t|\nu,\sigma,A) = \int_0^A p_a(x)p_s((1-x)/t)\,dx\\$$

which can be expressed as the sum of two error functions.

But already when checking this step numerically, I get a discrepancy between estimated (by sampling) and calculated distribution:

http://i45.tinypic.com/2da0ew5.png

Why do the histogram and the calculated distribution do not match?

This is the code I used:

n=10000000

A=0.7
nu=.7
sigma=.1

# sampling from the target distribution
s=rnorm( n, mean=nu, sd=sigma )
a=runif( n, min=0, max=A )
t=(1-a)/s
hist(t,200, freq=F, xlim=c(0,5), ylim=c(0,2.5))


# plot the analytical result
analytic <- function(t, A, nu, sigma ){
  tmp <- function(x, A, t, nu, sigma){
     return (1/A*dnorm( (1-x)/t, mean=nu, sd=sigma) )
  }
  return( integrate( tmp, 0, A, A=A, t=t, nu=nu, sigma=sigma)$value)
}

x=seq(0,5,by=.01)
y=rep(0,length(x))
for( i in seq(1,length(x)) ){
  y[i]=analytic(x[i], A, nu, sigma)
}
lines( x, y, col="red", type="l")

Dividing a uniform by a normal random variable: What's the distribution?

I have two random variables $s\sim \mathcal{N}(\nu,\sigma)$ and $a\sim \mathcal{U}(0,A)$, $0<A<1$, calculate a third r.v. $t=(1-a)/s$ and want to find its distribution $p(t|\nu,\sigma,A)$.

My reasoning is, that for any value of $a$, there is exactly one $s=(1-a)/t$ such that the $(a,s)$ pair will produce $t$ and I will therefore have to integrate over the probabilities for these values:

$$p(t|\nu,\sigma,A) = \int_0^A p_a(x)p_s((1-x)/t)\,\mathrm dx\\$$

which can be expressed as the sum of two error functions.

But already when checking this step numerically, I get a discrepancy between estimated (by sampling) and calculated distribution:

http://i45.tinypic.com/2da0ew5.png

Why do the histogram and the calculated distribution do not match?

This is the code I used:

n=10000000

A=0.7
nu=.7
sigma=.1

# sampling from the target distribution
s=rnorm( n, mean=nu, sd=sigma )
a=runif( n, min=0, max=A )
t=(1-a)/s
hist(t,200, freq=F, xlim=c(0,5), ylim=c(0,2.5))


# plot the analytical result
analytic <- function(t, A, nu, sigma ){
  tmp <- function(x, A, t, nu, sigma){
     return (1/A*dnorm( (1-x)/t, mean=nu, sd=sigma) )
  }
  return( integrate( tmp, 0, A, A=A, t=t, nu=nu, sigma=sigma)$value)
}

x=seq(0,5,by=.01)
y=rep(0,length(x))
for( i in seq(1,length(x)) ){
  y[i]=analytic(x[i], A, nu, sigma)
}
lines( x, y, col="red", type="l")
added 9 characters in body
Source Link
thias
  • 965
  • 8
  • 21

I have two random variables $s\sim \mathcal{N}(\nu,\sigma)$ and $a\sim \mathcal{U}(0,A)$, $0<A<1$, calculate a third r.v. $t=(1-a)/s$ and want to find its distribution $p(t|\nu,\sigma,A)$.

My reasoning is, that for any value of $a$, there is exactly one $s=(1-a)/t$ such that the $(a,s)$ pair will produce $t$ and I will therefore have to integrate over the probabilities for these values:

$$p(t|\nu,\sigma,A) = \int_0^A p_a(x)p_s((1-x)/t)\,dx\\$$

which can be expressed as the sum of two error functions.

But already when checking this step numerically, I get a discrepancy between estimated (by sampling) and calculated distribution:

http://i45.tinypic.com/2da0ew5.png

Why do the histogram and the calculated distribution do not match?

This is the code I used:

n=10000000

A=0.7
nu=.7
sigma=.1

# sampling from the target distribution
s=rnorm( n, mean=nu, sd=sigma )
a=runif( n, min=0, max=A )
t=(1-a)/s
hist(t,200, freq=F, xlim=c(0,5), ylim=c(0,2.5))


# plot the analytical result
analytic <- function(t, A, nu, sigma ){
  tmp <- function(x, A, t, nu, sigma){
     return (1/A*dnorm( (1-x)/t, mean=nu, sd=sigma) )
  }
  return( integrate( tmp, 0, A, A=A, t=t, nu=nu, sigma=sigma)$value)
}

x=seq(0,5,by=.01)
y=rep(0,length(x))
for( i in seq(1,length(x)) ){
  y[i]=analytic(x[i], A, nu, sigma)
}
lines( x, y, col="red", type="l")

I have two random variables $s\sim \mathcal{N}(\nu,\sigma)$ and $a\sim \mathcal{U}(0,A)$, calculate a third r.v. $t=(1-a)/s$ and want to find its distribution $p(t|\nu,\sigma,A)$.

My reasoning is, that for any value of $a$, there is exactly one $s=(1-a)/t$ such that the $(a,s)$ pair will produce $t$ and I will therefore have to integrate over the probabilities for these values:

$$p(t|\nu,\sigma,A) = \int_0^A p_a(x)p_s((1-x)/t)\,dx\\$$

which can be expressed as the sum of two error functions.

But already when checking this step numerically, I get a discrepancy between estimated (by sampling) and calculated distribution:

http://i45.tinypic.com/2da0ew5.png

Why do the histogram and the calculated distribution do not match?

This is the code I used:

n=10000000

A=0.7
nu=.7
sigma=.1

# sampling from the target distribution
s=rnorm( n, mean=nu, sd=sigma )
a=runif( n, min=0, max=A )
t=(1-a)/s
hist(t,200, freq=F, xlim=c(0,5), ylim=c(0,2.5))


# plot the analytical result
analytic <- function(t, A, nu, sigma ){
  tmp <- function(x, A, t, nu, sigma){
     return (1/A*dnorm( (1-x)/t, mean=nu, sd=sigma) )
  }
  return( integrate( tmp, 0, A, A=A, t=t, nu=nu, sigma=sigma)$value)
}

x=seq(0,5,by=.01)
y=rep(0,length(x))
for( i in seq(1,length(x)) ){
  y[i]=analytic(x[i], A, nu, sigma)
}
lines( x, y, col="red", type="l")

I have two random variables $s\sim \mathcal{N}(\nu,\sigma)$ and $a\sim \mathcal{U}(0,A)$, $0<A<1$, calculate a third r.v. $t=(1-a)/s$ and want to find its distribution $p(t|\nu,\sigma,A)$.

My reasoning is, that for any value of $a$, there is exactly one $s=(1-a)/t$ such that the $(a,s)$ pair will produce $t$ and I will therefore have to integrate over the probabilities for these values:

$$p(t|\nu,\sigma,A) = \int_0^A p_a(x)p_s((1-x)/t)\,dx\\$$

which can be expressed as the sum of two error functions.

But already when checking this step numerically, I get a discrepancy between estimated (by sampling) and calculated distribution:

http://i45.tinypic.com/2da0ew5.png

Why do the histogram and the calculated distribution do not match?

This is the code I used:

n=10000000

A=0.7
nu=.7
sigma=.1

# sampling from the target distribution
s=rnorm( n, mean=nu, sd=sigma )
a=runif( n, min=0, max=A )
t=(1-a)/s
hist(t,200, freq=F, xlim=c(0,5), ylim=c(0,2.5))


# plot the analytical result
analytic <- function(t, A, nu, sigma ){
  tmp <- function(x, A, t, nu, sigma){
     return (1/A*dnorm( (1-x)/t, mean=nu, sd=sigma) )
  }
  return( integrate( tmp, 0, A, A=A, t=t, nu=nu, sigma=sigma)$value)
}

x=seq(0,5,by=.01)
y=rep(0,length(x))
for( i in seq(1,length(x)) ){
  y[i]=analytic(x[i], A, nu, sigma)
}
lines( x, y, col="red", type="l")
edited body
Source Link
thias
  • 965
  • 8
  • 21
Loading
Tweeted twitter.com/#!/StackStats/status/225946751029362688
edited body
Source Link
thias
  • 965
  • 8
  • 21
Loading
added 6 characters in body
Source Link
thias
  • 965
  • 8
  • 21
Loading
Source Link
thias
  • 965
  • 8
  • 21
Loading