예제 #1
0
double MaxFlowSegmentation::get_histoprob(int index0)
{
	int pix = 0;
	if(threeD==true)	pix = image_data[3*index0+0];
	else pix = image_data[index0];

	double probA = compute_prob(mean_histogram_bg, stdv_histogram_bg, normal_mean_histogram_bg, normal_stdv_histogram_bg, pix);
	double probB = compute_prob(mean_histogram_fg, stdv_histogram_fg, normal_mean_histogram_fg, normal_stdv_histogram_fg, pix);

	if(probB==0.0) probB = 0.000000001;

	//double log_like = -2*(log(w_weight*probA)/log(probB));
	double log_like = (w_weight*probA)/probB;

	return log_like;
}
예제 #2
0
double Joint_like(int num_times, double T[pop_dim], double pop_size[num_times], double p[2])
{
int num_haps = p[0];
//int num_times = p[1];
double lambda[num_times];
int marker = 0;
int i=0;


for(i=0; i<num_times; i++)
{

//printf("pop_size[%d] = %f\n",i, pop_size[i]);
 if (pop_size[i] < 100) //&& pop_size[i] < 100000000){}
// else{ }//break;   }
{
 marker = 1;
//	printf("MARKER = %f\n", 1.0);
return(10000000000000);
}

lambda[i] = (1 / pop_size[i]);
}


precompute_L_ind_quantities( num_haps, num_times, T, pop_size );



double joint = 0;
// int l=0;
//     for(l=0; l<num_bins; l++)
//     {
// 	int m;
// 	for(m = 0; m < num_times; m++)
// 	{	
// 			exp_part_L[m] = exp( T[m] * mu * bin_center[l] );
// 	}

int l=0;
    for(l=0; l< num_loci; l++)
    {
	if(bin_center[l] > 1)
	{

	//	printf("asdasdfbin_center = %f", bin_center[l]);
		int m;
		for(m = 0; m < num_times; m++)
		{	
				exp_part_L[m] = exp( T[m] * mu * bin_center[l] );
		}
	}
    }

double temp = 0;
double tile = 0;
double total = 0;
for(i=0; i< num_quantiles; i++)
{
	temp =compute_prob(num_haps, num_times, quant_values[i], T, pop_size, lambda);
	tile = quant_list[i];
	total = total +  pow( (1 - temp) - tile, 2);
	//if (i % 100 == 0) { printf("computed_quant_values(%d) = %f \t tile = %f\n", i, 1- temp, tile); }
}
total = sqrt(total / num_quantiles);


 //double temp1 = compute_prob(num_haps, num_times, 236.0, T, pop_size, lambda);
//double temp2 = compute_prob(num_haps, num_times, 658.0, T, pop_size, lambda);
// double temp3 = compute_prob(num_haps, num_times, 1640.0, T, pop_size, lambda);
// //printf("temp2 = %f\n", temp2);
// 
//total = pow(fabs(temp3- .25),2);

//double temp4 = compute_prob(num_haps, num_times, bin_center[l], T, pop_size, lambda);
printf("total = %f\n", total);
if (total >-100 && total < 100){}
else{abort();}
return ( total );
}
예제 #3
0
float* compute_weight(char* matrix, float* weight, char** miss, char** hit)
{
	float* n = new float[featurecount];
	init(n);
	auto dis = new float*[msize];
	for (int i = 0; i < msize; i++)
	{
		dis[i] = new float[msize];
		init(dis[i]);
	}
	distance(matrix, weight,dis);
	for (int i = 0; i < samplecount; ++i)
	{
		float* m_n = new float[featurecount];
		float* h_n = new float[featurecount];
		init(m_n);
		init(h_n);
		for (int j = 0; j < samplecount; ++j)
		{
			if (i == j)
			{
				continue;
			}
			if (miss[i][j] == 1)
			{
				float a = compute_prob(dis, j, i, miss[i]);
				char* x1 = new char[featurecount];
				getLine(matrix,x1,i);
				char* x2 = new char[featurecount];
				getLine(matrix, x2, j);
				char* b = new char[featurecount];
				sub(x1,x2,b);
				for (int k = 0; k < featurecount; k++)
				{
					m_n[k] += a*b[k];
				}
				delete[] b;
				delete[] x1;
				delete[] x2;
			}
			else if(hit[i][j]==1)
			{
				float a = compute_prob(dis, j, i, hit[i]);
				char* x1 = new char[featurecount];
				getLine(matrix, x1, i);
				char* x2 = new char[featurecount];
				getLine(matrix, x2, j);
				char* b = new char[featurecount];
				sub(x1, x2, b);
				for (int k = 0; k < featurecount; k++)
				{
					h_n[k] += a*b[k];
				}
				delete[] b;
				delete[] x1;
				delete[] x2;
			}
		}
		float gn = compute_gn(matrix, dis, i, miss[i]);
		for (int j = 0; j < featurecount; ++j)
		{
			n[j] += gn*(m_n[j] - h_n[j]);
		}
		delete[] m_n;
		delete[] h_n;
	}
	
	for (int i = 0; i < msize; i++)
	{
		delete[] dis[i];
	}
	delete[] dis;
	for (int i = 0; i < featurecount; ++i)
	{
		if (n[i] < 0)
		{
			n[i] = 0;
		}
		else
		{
			n[i] /= 1000;
		}
	}
	float n_norm = norm_2(n);
	for (int i = 0; i < featurecount; ++i)
	{
		n[i] /= n_norm;
	}
	return n;
}