Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7747569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:33:46+00:00 2026-06-01T10:33:46+00:00

I would like to calculate a density function of a distribution whose characteristics function

  • 0

I would like to calculate a density function of a distribution whose characteristics function is known. As a simple example take the normal distribution.

norm.char<-function(t,mu,sigma) exp((0+1i)*t*mu-0.5*sigma^2*t^2)

and then I would like to use R’s fft function. but I don’t get the multiplicative constants right and I have to reorder the result (take the 2nd half and then the first half of the values). I tried something like

 xmax = 5
 xmin = -5
 deltat = 2*pi/(xmax-xmin)
 N=2^8
 deltax = (xmax-xmin)/(N-1)
 x = xmin + deltax*seq(0,N-1)
 t = deltat*seq(0,N-1)
 density = Re(fft(norm.char(t*2*pi,mu,sigma)))
 density = c(density[(N/2+1):N],density[1:(N/2)])

But this is still not correct. Does anybody know a good reference on the fft in R in the context of density calculations? Obviously the problem is the mixture of the continuous FFT and the discrete one. Can anybody recommend a procedure?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:33:47+00:00Added an answer on June 1, 2026 at 10:33 am

    It is just cumbersome: take a pen and paper,
    write the integral you want to compute
    (the Fourier transform of the characteristic function),
    discretize it, and rewrite the terms so that they look like
    a discrete Fourier transform (the FFT assumes that the interval starts
    at zero).

    Note that fft is an unnormalized transform: there is no 1/N factor.

    characteristic_function_to_density <- function(
      phi, # characteristic function; should be vectorized
      n,   # Number of points, ideally a power of 2
      a, b # Evaluate the density on [a,b[
    ) {
      i <- 0:(n-1)            # Indices
      dx <- (b-a)/n           # Step size, for the density
      x <- a + i * dx         # Grid, for the density
      dt <- 2*pi / ( n * dx ) # Step size, frequency space
      c <- -n/2 * dt          # Evaluate the characteristic function on [c,d]
      d <-  n/2 * dt          # (center the interval on zero)
      t <- c + i * dt         # Grid, frequency space
      phi_t <- phi(t)
      X <- exp( -(0+1i) * i * dt * a ) * phi_t
      Y <- fft(X)
      density <- dt / (2*pi) * exp( - (0+1i) * c * x ) * Y
      data.frame(
        i = i,
        t = t,
        characteristic_function = phi_t,
        x = x,
        density = Re(density)
      )
    }
    
    d <- characteristic_function_to_density(
      function(t,mu=1,sigma=.5) 
        exp( (0+1i)*t*mu - sigma^2/2*t^2 ),
      2^8,
      -3, 3
    )
    plot(d$x, d$density, las=1)
    curve(dnorm(x,1,.5), add=TRUE)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, on July 5, 2010, I would like to calculate the string July
I would like to calculate an inverse mask for an unsigned char.meaning if the
I would like to calculate/estimate the amount of time file will take for download.
I would like to calculate, in PHP, the percentage of a number. For example:
I would like to calculate total order amount in the previous month. I got
I would like to calculate my total order amount in the previous week. I
I would like to calculate the similarity between users, which is reciprocal. similarity[:user1][:user2] ==
I would like to calculate a timestamp based on the input date. I would
Lets say I would like to calculate percents and do: double n = ...;
I have a matrix mat and would like to calculate the mean of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.