analistica/ex-4/lib.h
2020-07-05 11:36:22 +02:00

40 lines
756 B
C

#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.
//
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);