analistica/ex-4/lib.h

40 lines
756 B
C
Raw Normal View History

#pragma once
#include <math.h>
#include <stdlib.h>
// Histogram struct.
//
struct bin
{
size_t amo; // Amount of events in the bin.
double sum; // Sum of |p_v|s of all the events in the bin.
};
// Minimization struct.
//
struct parameters
{
struct bin* histo; // Histogram
size_t n; // Number of bins
double step; // Bin width
};
/////////////////////////////////////////////////////////////////
// Minimization wrapper.
//
2020-06-01 15:45:10 +02:00
double chi2 (double p_max, void* params);
// Expected function.
//
double expected (double x, double p_max);
// First derivative of the expected function.
//
double exp1d (double x, double p_max);
// Second derivative of the expected function.
//
double exp2d (double x, double p_max);