Example #1
0
void fake_data()
{
	/* use this function to create fake data to test your analysis, before you try real data */

	/* how many data in all? */
	int numdata = 999;

	/* create internal table to hold data */
	table_create("fakedata");

	/* define table structure */ 
	// table_addcolumn("fakedata", <column_name>);
	// ...

	/* create fake data */
	for(int ii = 0; ii < numdata; ii++)
	{
		/* compute values of a fake data row */

		/* write these values to the data (as if reading real data) */
		// table_writevalue("fakedata", <column_name>, ii, <computed_value>);
		// ...
	}

	/* output data to use later on */
	table_output("fakedata","./workspace/mymodel_fakedata.txt");

	return;
}
Example #2
0
/**
 * val_analyse:
 * @widgets:           The widget layout
 * @tracks_and_layers: A list of #vik_trw_track_list_t
 * @include_invisible: Whether to include invisible layers and tracks
 *
 * Analyse each item in the @tracks_and_layers list
 *
 */
void val_analyse ( GtkWidget *widgets[], GList *tracks_and_layers, gboolean include_invisible, gboolean extended )
{
	val_reset ( TS_TRACKS );

	GList *gl = g_list_first ( tracks_and_layers );
	if ( gl ) {
		g_list_foreach ( gl, (GFunc) val_analyse_item_maybe, GINT_TO_POINTER(include_invisible) );
	}

	table_output ( tracks_stats[TS_TRACKS], widgets, extended );

	g_list_free_full ( tracks_stats[TS_TRACKS].e_list, g_free );
}
Example #3
0
void final_output()
{
	char fname[100];

	/* create file name for output -- fname gets the 'path' and analysis name */
	get_filzbach_path(fname, 100);
	/* now your bit to add to the path */
	strcat(fname,"_my_output.txt");

	/* print internal table out to file with name taken from above */
	table_output("mydata",fname);

	return;
}
Example #4
0
void fake_data()
{
    /* use this to create fake data to test your analysis, before you try real data */
    /* do we get these parameters back out again? */
    double true_m0 = 2.0, true_beta=0.010, true_gph=0.40, true_gdepth=0.00, true_gmoss=0.20; // nb -- no effect of depth
    double phref=7.0, depthref=10.0, mossref=0.0;
    double ph, depth, moss, lambda, count;
    int ii;

    /* create internal table to hold data, and model predictions (written in later) */
    table_create("fakedata");
    table_addcolumn("fakedata","ph");
    table_addcolumn("fakedata","depth");
    table_addcolumn("fakedata","moss");
    table_addcolumn("fakedata","count");

    /* how many data in all? */
    numdata = 999;

    for(ii=0 ; ii<numdata ; ii++)
    {
        /* draw fakedata values for factors: ph, depth, moss */
        depth = random(0.0,20.0);
        ph = 5.0 + 2.0*(depth/20.0) + random(0.0,2.0);

        if(random(0.0,1.0)<0.50)
            moss = 1.0;
        else
            moss = 0.0;

        /* calculte lambda (=average seedling count) for these conditions */
        lambda = true_beta + true_m0*exp( true_gph*(ph-phref) + true_gdepth*(depth-depthref) + true_gmoss*(moss-mossref));
        /* draw fakedata no. of seedlings from poisson with this lambda */
        count = poisson_draw(lambda);

        /* write these values to the data (as if reading real data) */
        table_writevalue("fakedata","moss",ii,moss);
        table_writevalue("fakedata","ph",ii,ph);
        table_writevalue("fakedata","depth",ii,depth);
        table_writevalue("fakedata","count",ii,count);
    }

    table_output("fakedata","./workspace/EgDataz2_seedrain.txt");

    return;
}
void fake_data()
{
	/* use this to create fake data to test your analysis, before you try real data */
	/* do we get these parameters back out again? */
	double true_sigma1 = 9.0;
	double true_mean1 = 37.0;
	double true_sigma2 = 25.0;
	double true_mean2 = 100.0;
	double true_q = 0.80;

	/* how many data in all? */
	int numdata = 99;

	/* create internal table to hold data */
	table_create("fakedata");
	table_addcolumn("fakedata","y");

	for(int ii=0 ; ii<numdata ; ii++)
	{
		/* first, randomly choose normal1, or normal 2 */
		int choice;
		if(random(0.0,1.0)<true_q)
			choice = 1;
		else
			choice = 2;

		/* now draw random value for y from the appropriate normal distribution */
		double y;
		if(choice==1)
			y = normal_draw(true_mean1,true_sigma1);
		if(choice==2)
			y = normal_draw(true_mean2,true_sigma2);

		/* write the y value to the data (as if reading real data) */
		table_writevalue("fakedata","y",ii,y);
	}

	/* output data to use later on */
	table_output("fakedata","./workspace/eg03_mixednormal_fakedata.txt");

	return;
}
Example #6
0
void final_output()
{
    /* create link to file */
    char fname[100];

    /* create file name for output */
    get_filzbach_path(fname, 100);
    /* now your bit */
    strcat(fname,"_my_output.txt");

    /* we're ouputting predictions */
    /* in this case, one set of preds with params set at posterior means */
    /* but could output an ensemble of predictions, with each set with param vector drawn at random */
    /* see the commented out line below... */
    params_set_to_posterior_mean();
    // params_draw_random_vector();
    /* in this case it's the likelihood function that writes the preds into the table */
    likelihood();
    /* output */
    table_output("mydata",fname);

    return;

}