lundi 14 septembre 2015

How do I use the MATLAB function randn in c++?

I am trying to implement this code but I am getting the following compiler error: randn wasn't declared in the scope.

void levyflt()
{
  int j;
  double beta=1.5,sigma,rand_num;

  sigma=pow((tgamma(1+beta)*sin(M_PI*beta/2)/(tgamma((1+beta)/2)*beta*pow(2,((beta-1)/2)))),(1/beta));

  for(j=0;j<d;j++)
  {

    rand_num=randn(-1,1);
    u[j]=rand_num*sigma;
    rand_num=randn(-1,1);

    v[j]=rand_num;
    step[j]=u[j]/pow(fabs(v[j]),(1/beta));
    L[j]=0.01*step[j];
  }


  cout<<L[j];
}




Aucun commentaire:

Enregistrer un commentaire