Commit 18294d46 authored by Antonio Portero's avatar Antonio Portero

First 'Stable' version

parents
This Software is licensed to you under the Creative Commons License.
License name: Creative Commons Attribution 4.0 International Public License
URL: https://creativecommons.org/licenses/by/4.0/legalcode
Summary:
You are free to:
Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
Under the following terms:
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
Notices:
You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
INSTALLATION
The software compiles in GNU/Linux
To compile the code:
>> cd workers
or
>> cd genpop
>> g++ -g -Wall -std=c++11 -I/xilib/cpp/src -L/xilib/scpp/src/chisqr.a log_normal.cpp model_uncer4.cpp -o uncer4 -lm -lstdc++ -DAE_USE_ALLOC_COUNTER -DAE_DEBUG4POSIX ./xilib/cpp/src/*.cpp
square: http://www.alglib.net/download.php#cpp
To execute the code:
./uncer4
REFERENCE
- Author: Antoni Portero
- Date: March 2020
- Title of program: BPA-UNCER.
- Code version 1
- Type source code
- URL: https://gitlab.version.fz-juelich.de/portero1/bpa-uncer
- GIT: git clone
When writing a report and citing within the text, the following method (based on common IEEE and ACM citiation rules for other types of references) can be used:
Radka Prichystalova, Antoni Portero, "Methodological challenges for assessing the disease burden of chemicals and associated costs: example of BPA in thermal paper", TBD
This diff is collapsed.
#set terminal postfile (These commented lines would be used to )
#set output "d2_plot.ps" (generate a postscript file. )
#set terminal png size 1920,1080 enhanced font "Arial,8" #dashed
#set terminal pdfcairo monochrome enhanced font "Arial,8" dashed
#set terminal pdf monochrome enhanced dashed
#set terminal postscript monochrome enhanced dashed
#set terminal pslatex monochrome dashed rotate
#set terminal svg dynamic enhanced dashed
#set terminal hp500c {<res>} {<comp>}
#set terminal hp500c 1000 tiff
set terminal pngcairo size 1920,1080 enhanced dashed font "Arial,16"
set output 'POCE_uncertainty.png'
#set size ratio 3
set multiplot layout 3,1 title "Uncertainty POCE" font "Arial,24"
set title font "Arial,20"
set key font "Arial,16"
set xtics font "Arial,16"
set ytics font "Arial,16"
set xlabel font "Arial,16"
set ylabel font "Arial,16"
set termoption dashed
#set term pdf dashed monochrome
set title "POCE uncertainty example"
#set ylabel "Distance from Ideal Performance"
#set y2label "Number of allocated cores"
set xrange [0:5]
set xtics ("0.1" 0, "1" 1, "10" 2,"100" 3,"1000" 4,"10000" 5)
set ylabel "Percentage (0-1)"
#set xrange [0:600]
set key top right
plot "./set_solution.txt" using 1:2 axes x1y1 title'0.1' with points ps 4.0, \
"./set_solution.txt" using 3:4 axes x1y1 title'1' with points ps 4.0, \
"./set_solution.txt" using 5:6 axes x1y1 title'0.1' with points ps 4.0, \
"./set_solution.txt" using 7:8 axes x1y1 title'10' with points ps 4.0, \
"./set_solution.txt" using 9:10 axes x1y1 title'100' with points ps 4.0, \
"./set_solution.txt" using 11:12 axes x1y1 title'1000' with points ps 4.0, \
"./set_solution.txt" using 13:14 axes x1y1 title'10000' with points ps 4.0, \
"./uncerIMOE.txt" using 1:2 axes x1y1 with points ps 4.0, \
"./uncerIMOE.txt" using 3:4 axes x1y1 with points ps 4.0, \
"./uncerIMOE.txt" using 5:6 axes x1y1 with points ps 4.0, \
"./uncerIMOE.txt" using 7:8 axes x1y1 with points ps 4.0, \
"./uncerIMOE.txt" using 9:10 axes x1y1 with points ps 4.0, \
"./uncerIMOE.txt" using 11:12 axes x1y1 with points ps 4.0, \
"./uncerIMOE.txt" using 13:14 axes x1y1 with points ps 4.0,
set title "POCE uncertainty INTER"
#set ylabel "Distance from Ideal Performance"
#set y2label "Number of allocated cores"
set xrange [0:5]
set xtics ("0.1" 0, "1" 1, "10" 2,"100" 3,"1000" 4,"10000" 5)
set ylabel "Percentage (0-1)"
#set xrange [0:600]
set key top right
plot "./inter_solution.txt" using 1:2 axes x1y1 title'0.1' with points ps 4.0, \
"./inter_solution.txt" using 3:4 axes x1y1 title'1' with points ps 4.0, \
"./inter_solution.txt" using 5:6 axes x1y1 title'0.1' with points ps 4.0, \
"./inter_solution.txt" using 7:8 axes x1y1 title'10' with points ps 4.0, \
"./inter_solution.txt" using 9:10 axes x1y1 title'100' with points ps 4.0, \
"./inter_solution.txt" using 11:12 axes x1y1 title'1000' with points ps 4.0, \
"./inter_solution.txt" using 13:14 axes x1y1 title'10000' with points ps 4.0, \
set title "POCE uncertainty INTRA"
#set ylabel "Distance from Ideal Performance"
#set y2label "Number of allocated cores"
set xrange [0:5]
set xtics ("0.1" 0, "1" 1, "10" 2,"100" 3,"1000" 4,"10000" 5)
set ylabel "Percentage (0-1)"
#set xrange [0:600]
set key top right
plot "./POCE_intra.txt" using 1:2 axes x1y1 title'0.1' with points ps 4.0, \
"./POCE_intra.txt" using 3:4 axes x1y1 title'1' with points ps 4.0, \
"./POCE_intra.txt" using 5:6 axes x1y1 title'0.1' with points ps 4.0, \
"./POCE_intra.txt" using 7:8 axes x1y1 title'10' with points ps 4.0, \
"./POCE_intra.txt" using 9:10 axes x1y1 title'100' with points ps 4.0, \
"./POCE_intra.txt" using 11:12 axes x1y1 title'1000' with points ps 4.0, \
"./POCE_intra.txt" using 13:14 axes x1y1 title'10000' with points ps 4.0, \
This diff is collapsed.
#include<stdio.h>
main(){
FILE *file;
if ((file = fopen("default_inter.txt", "w+"))==NULL)
{
printf("IEXP: No such file, sorry.\n");
//exit(1);
}//if
int i=0;
for(i=0;i<50000;i++) fprintf(file,"%lf\n",1.0);
}
This diff is collapsed.
This diff is collapsed.
double log_normal_cdf ( double x, double mu, double sigma );
double log_normal_cdf_inv ( double cdf, double mu, double sigma );
void log_normal_cdf_values ( int *n_data, double *mu, double *sigma,
double *x, double *fx );
int log_normal_check ( double mu, double sigma );
double log_normal_mean ( double mu, double sigma );
double log_normal_pdf ( double x, double mu, double sigma );
double log_normal_sample ( double mu, double sigma, int *seed );
double log_normal_variance ( double mu, double sigma );
double normal_01_cdf ( double x );
double normal_01_cdf_inv ( double cdf );
double normal_cdf ( double x, double mu, double sigma );
double normal_cdf_inv ( double cdf, double mu, double sigma );
int normal_check ( double mu, double sigma );
double r8_uniform_01 ( int *seed );
double r8poly_value_horner ( int n, double a[], double x );
double r8vec_max ( int n, double x[] );
double r8vec_mean ( int n, double x[] );
double r8vec_min ( int n, double x[] );
double r8vec_variance ( int n, double x[] );
void timestamp ( );
double log_normal_cdf ( double x, double mu, double sigma );
double log_normal_cdf_inv ( double cdf, double mu, double sigma );
void log_normal_cdf_values ( int *n_data, double *mu, double *sigma,
double *x, double *fx );
int log_normal_check ( double mu, double sigma );
double log_normal_mean ( double mu, double sigma );
double log_normal_pdf ( double x, double mu, double sigma );
double log_normal_sample ( double mu, double sigma, int *seed );
double log_normal_variance ( double mu, double sigma );
double normal_01_cdf ( double x );
double normal_01_cdf_inv ( double cdf );
double normal_cdf ( double x, double mu, double sigma );
double normal_cdf_inv ( double cdf, double mu, double sigma );
int normal_check ( double mu, double sigma );
double r8_uniform_01 ( int *seed );
double r8poly_value_horner ( int n, double a[], double x );
double r8vec_max ( int n, double x[] );
double r8vec_mean ( int n, double x[] );
double r8vec_min ( int n, double x[] );
double r8vec_variance ( int n, double x[] );
void timestamp ( );
<html>
<head>
<title>
LOG_NORMAL - The Log Normal Probability Density Function
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
LOG_NORMAL <br> The Log Normal Probability Density Function
</h1>
<hr>
<p>
<b>LOG_NORMAL</b>
is a C library which
can evaluate quantities associated with the log normal Probability
Density Function (PDF).
</p>
<p>
If X is a variable drawn from the log normal distribution, then
correspondingly, the logarithm of X will have the normal distribution.
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files described and made available on this web page
are distributed under
<a href = "../../txt/gnu_lgpl.txt">the GNU LGPL license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>LOG_NORMAL</b> is available in
<a href = "../../c_src/log_normal/log_normal.html">a C version</a> and
<a href = "../../cpp_src/log_normal/log_normal.html">a C++ version</a> and
<a href = "../../f_src/log_normal/log_normal.html">a FORTRAN90 version</a> and
<a href = "../../m_src/log_normal/log_normal.html">a MATLAB version</a> and
<a href = "../../py_src/log_normal/log_normal.html">a Python version</a>.
</p>
<h3 align = "center">
Related Data and Programs:
</h3>
<p>
<a href = "../../c_src/log_normal_truncated_ab/log_normal_truncated_ab.html">
LOG_NORMAL_TRUNCATED_AB</a>,
a C library which
returns quantities associated with the log normal Probability
Distribution Function (PDF) truncated to the interval [A,B].
</p>
<p>
<a href = "../../c_src/normal/normal.html">
NORMAL</a>,
a C library which
samples the normal distribution.
</p>
<p>
<a href = "../../c_src/prob/prob.html">
PROB</a>,
a C library which
evaluates, samples, inverts, and characterizes a number of
Probability Density Functions (PDF's)
and Cumulative Density Functions (CDF's), including anglit, arcsin,
benford, birthday, bernoulli, beta_binomial, beta, binomial, bradford,
burr, cardiod, cauchy, chi, chi squared, circular, cosine, deranged,
dipole, dirichlet mixture, discrete, empirical, english sentence and
word length, error, exponential, extreme values, f, fisk, folded normal,
frechet, gamma, generalized logistic, geometric, gompertz, gumbel,
half normal, hypergeometric, inverse gaussian, laplace, levy, logistic,
log normal, log series, log uniform, lorentz, maxwell, multinomial,
nakagami, negative binomial, normal, pareto, planck, poisson,
power, quasigeometric, rayleigh, reciprocal, runs, sech, semicircular,
student t, triangle, uniform, von mises, weibull, zipf.
</p>
<p>
<a href = "../../c_src/truncated_normal/truncated_normal.html">
TRUNCATED_NORMAL</a>,
a C library which
works with the truncated normal distribution over [A,B], or
[A,+oo) or (-oo,B], returning the probability density function (PDF),
the cumulative density function (CDF), the inverse CDF, the mean,
the variance, and sample values.
</p>
<p>
<a href = "../../c_src/uniform/uniform.html">
UNIFORM</a>,
a C library which
samples the uniform distribution.
</p>
<h3 align = "center">
Source Code:
</h3>
<p>
<ul>
<li>
<a href = "log_normal.c">log_normal.c</a>, the source code.
</li>
<li>
<a href = "log_normal.h">log_normal.h</a>, the include file.
</li>
</ul>
</p>
<h3 align = "center">
Examples and Tests:
</h3>
<p>
<ul>
<li>
<a href = "log_normal_prb.c">log_normal_prb.c</a>
a sample calling program.
</li>
<li>
<a href = "log_normal_prb_output.txt">log_normal_prb_output.txt</a>,
the output file.
</li>
</ul>
</p>
<h3 align = "center">
List of Routines:
</h3>
<p>
<ul>
<li>
<b>LOG_NORMAL_CDF</b> evaluates the Lognormal CDF.
</li>
<li>
<b>LOG_NORMAL_CDF_INV</b> inverts the Lognormal CDF.
</li>
<li>
<b>LOG_NORMAL_CDF_VALUES</b> returns some values of the Log Normal CDF.
</li>
<li>
<b>LOG_NORMAL_CHECK</b> checks the parameters of the Lognormal PDF.
</li>
<li>
<b>LOG_NORMAL_MEAN</b> returns the mean of the Lognormal PDF.
</li>
<li>
<b>LOG_NORMAL_PDF</b> evaluates the Lognormal PDF.
</li>
<li>
<b>LOG_NORMAL_SAMPLE</b> samples the Lognormal PDF.
</li>
<li>
<b>LOG_NORMAL_VARIANCE</b> returns the variance of the Lognormal PDF.
</li>
<li>
<b>LOG_SERIES_CDF</b> evaluates the Logarithmic Series CDF.
</li>
<li>
<b>NORMAL_01_CDF</b> evaluates the Normal 01 CDF.
</li>
<li>
<b>NORMAL_01_CDF_INV</b> inverts the standard normal CDF.
</li>
<li>
<b>NORMAL_CDF</b> evaluates the Normal CDF.
</li>
<li>
<b>NORMAL_CDF_INV</b> inverts the Normal CDF.
</li>
<li>
<b>NORMAL_CHECK</b> checks the parameters of the Normal PDF.
</li>
<li>
<b>R8_UNIFORM_01</b> returns a unit pseudorandom R8.
</li>
<li>
<b>R8POLY_VALUE</b> evaluates a double precision polynomial.
</li>
<li>
<b>R8VEC_MAX</b> returns the value of the maximum element in an R8VEC.
</li>
<li>
<b>R8VEC_MEAN</b> returns the mean of an R8VEC.
</li>
<li>
<b>R8VEC_MIN</b> returns the value of the minimum element in an R8VEC.
</li>
<li>
<b>R8VEC_VARIANCE</b> returns the variance of an R8VEC.
</li>
<li>
<b>TIMESTAMP</b> prints the current YMDHMS date as a time stamp.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../c_src.html">
the C source codes</a>.
</p>
<hr>
<i>
Last revised on 22 March 2015.
</i>
<!-- John Burkardt -->
</body>
</html>
#! /bin/bash
#
cp log_normal.h /$HOME/include
#
gcc -c -I/$HOME/include log_normal.c
if [ $? -ne 0 ]; then
echo "Errors compiling log_normal.c"
exit
fi
#
mv log_normal.o ~/libc/$ARCH/log_normal.o
#
echo "Library installed as ~/libc/$ARCH/log_normal.o"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// lognormal_distribution
double log_normal ( double x, double mu, double sigma ){
double lognormal;
double pi= 3.14159265358979323846;
//lognormal=(1/(sigma*x*sqrt(2*pi)*pow(sigma,2)))*exp(-pow((log(x)-mu),2)/(2*pow(sigma,2)));
//f(x)=(1/sqrt(2*pi*sigma^2))*exp(-(log(x)-mu)^2/(2*sigma^2))
lognormal=(1/(sqrt(2*pi)*sigma*x))*exp(-(pow((log(x)-sigma),2))/(2*pow(sigma,2)));
//lognormal_inv=1/lognormal;
return lognormal;
}
main(){
double mu=4;
double sigma=1.48;
double x=5;
double result=0;
double y=0,z,k;
y=log(5);
z=pow((log(x)-sigma),2.0);
result=log_normal(x,mu,sigma);
k=pow(4,2);
printf("RESULT:%lf %lf %lf %lf\n", result,y,(1/result),k);
}
# include <math.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include "log_normal.h"
int main ( );
void log_normal_cdf_test ( );
void log_normal_sample_test ( );
/******************************************************************************/
int main ( )
/******************************************************************************/
/*
Purpose:
MAIN is the main program for LOG_NORMAL_PRB.
Discussion:
LOG_NORMAL_PRB tests the LOG_NORMAL library.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
22 March 2016
Author:
John Burkardt
*/
{
timestamp ( );