diff --git a/.project b/.project
new file mode 100644
index 0000000..dace9a3
--- /dev/null
+++ b/.project
@@ -0,0 +1,19 @@
+
+
+ FourierStuff
+
+
+
+
+
+ de.walware.statet.r.builders.RSupport
+
+
+
+
+
+ de.walware.statet.base.StatetNature
+ de.walware.statet.r.RNature
+ de.walware.statet.r.RPkgNature
+
+
diff --git a/.settings/de.walware.r.core.prefs b/.settings/de.walware.r.core.prefs
new file mode 100644
index 0000000..b677fbb
--- /dev/null
+++ b/.settings/de.walware.r.core.prefs
@@ -0,0 +1,2 @@
+RProjectBuild/Package.name=FourierStuff
+eclipse.preferences.version=1
diff --git a/DESCRIPTION b/DESCRIPTION
new file mode 100644
index 0000000..53e7d72
--- /dev/null
+++ b/DESCRIPTION
@@ -0,0 +1,9 @@
+Package: FourierStuff
+Title: Some probability stuff around Fourier transforms
+Version: 0.1
+Date: 2014-01-06
+Author: Francois Pelletier
+Maintainer: Francois Pelletier
+Description: This is a package gathering different functions to work with the
+ characteristic function and Fourier transforms
+License: LGPL-3
diff --git a/NAMESPACE b/NAMESPACE
new file mode 100644
index 0000000..e69de29
diff --git a/R/fft.density.R b/R/fft.density.R
new file mode 100644
index 0000000..ca4e257
--- /dev/null
+++ b/R/fft.density.R
@@ -0,0 +1,34 @@
+# Get density from characteristic function
+#
+# Author: François Pelletier
+###############################################################################
+
+#' Get density from characteristic function
+#'
+#' @param char.fun Vectorized characteristic function
+#' @param n Amount of discretization points
+#' @param min Lower bound for density function
+#' @param max Upper bound for density function
+#' @return A data.frame object containing
+#' @return transform.grid: transform variate grid
+#' @return char.fun.t: characteristic function evaluated at t
+#' @return density.grid: density function grid
+#' @return density.value: density function evaluated at point x
+#' @author François Pelletier
+fft.density <- function(char.fun,n,min,max,...)
+{
+ index <- 0:(n-1) # Index
+ density.step <- (max-min)/n # Step for density function
+ density.grid <- min + index * density.step # Grid for density function
+ transform.step <- 2*pi / ( n * density.step) # Step for transform variate
+ lbound.char.fun <- -n/2 * transform.step # Evaluate characteristic function on range [c,d]
+ ubound.char.fun <- n/2 * transform.step # Range centered at 0
+ transform.grid <- lbound.char.fun + index * transform.step # Grid for transform variate
+ char.fun.t <- char.fun(transform.grid,...) # Evaluate characteristifc function
+ tilted.char.fun.t <- exp( -1i * index * transform.step * min ) * char.fun.t # Tilt characteristic function
+ density.value <- Re(transform.step / (2*pi) * exp( - 1i * lbound.char.fun * density.grid ) * fft(tilted.char.fun.t)) #Use FFT to get density value, then untilt and normalize
+ data.frame(transform.grid,char.fun.t,density.grid,density.value)
+}
+
+
+
diff --git a/man/fft.density.Rd b/man/fft.density.Rd
new file mode 100644
index 0000000..f83c013
--- /dev/null
+++ b/man/fft.density.Rd
@@ -0,0 +1,33 @@
+\name{fft.density}
+\alias{fft.density}
+\title{Get density from characteristic function}
+\usage{
+fft.density(char.fun, n, min, max, ...)
+}
+\arguments{
+ \item{char.fun}{Vectorized characteristic function}
+
+ \item{n}{Amount of discretization points}
+
+ \item{min}{Lower bound for density function}
+
+ \item{max}{Upper bound for density function}
+}
+\value{
+A data.frame object containing
+
+transform.grid: transform variate grid
+
+char.fun.t: characteristic function evaluated at t
+
+density.grid: density function grid
+
+density.value: density function evaluated at point x
+}
+\description{
+Get density from characteristic function
+}
+\author{
+François Pelletier
+}
+