 
     // Cuda grid launch
     dim3 nThreads(256);
-    dim3 nBlocks((n + nThreads.x-1) / nThreads.x);
+    dim3 nBlocks((ndata + nThreads.x-1) / nThreads.x);
     printf("nBlocks: %d\n", nBlocks.x);  // no more than 64k blocks!
     if (nBlocks.x > 65535)
     {

        double* p_prop_cholfact = thrust::raw_pointer_cast(&d_prop_cholfact[0]);
        double* p_logdens = thrust::raw_pointer_cast(&d_logdens[0]);
        int current_iter = i + 1;
        update_chi<<<nBlocks,nThreads>>>(p_chi, p_meas, p_meas_unc, n, p_logdens, p_prop_cholfact, devStates, current_iter);

        // Generate new theta in parallel with GPU calculation above
        thrust::host_vector<double> proposed_theta(dim_theta);

     collection of the mean and variances of the normal distributions.
    */

    int ndata = 1000; // # of data points

    double mu_norm = 8.5 * log(10.0);  // Average value of the natural logarithm of the SED normalization
    double sig_norm = 0.5 * log(10.0);  // Standard deviation in the SED normalization
