Log-likelihood for a linear function in CUDA

I am trying to compute log-likelihood for the model y = θ1 + x*θ2 + ε. I am stuck in here and need help.

'''

global void linearm( float theta_1, float theta_2, int N, const float* xs, const float* noise, float* ys) { uint index = blockDim.x * blockIdx.x + threadIdx.x;

ys[index] = theta_1 + xs[index] * theta_1 + noise[index];

}

global void normal_pdf( const float* xs, float mean, float stdev, float* ws) { uint index = blockDim.x * blockIdx.x + threadIdx.x;

float var = stdev * stdev;
float Z = 1.f / sqrt(M_2_PI * var);
float diff = xs[i] - mean;
float arg = -0.5 * diff * diff / var; 
ws[index] = Z * exp(arg); 

}

global void log_normal( const float* xs, float mean, float stdev, float* ws) { uint index = blockDim.x * blockIdx.x + threadIdx.x;

// log(Z * exp(arg)) = log(Z) + log(exp(arg)) = log(Z) + arg
float var = stdev * stdev; // sigma^2
float Z = 1.f / sqrt(M_2_PI * var);
float diff = xs[i] - mean;
float arg = -0.5 * diff * diff / var; 

ws[index] = log(Z) + arg;

}

global void normalise_ws( float* ws, float max_w) { uint index = blockDim.x * blockIdx.x + threadIdx.x;

ws[index] = exp(ws[index] - max_w);

}

'''

I am trying to find the log likelihood for the linear system in CUDA, I have done this also in PyCUDA but now trying to implement in CUDA only. I have less experience, so my question is, how I can proceed further after this?



Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)