2023-09-23 22:24:25 +00:00
|
|
|
#include "../../squiggle.h"
|
2023-11-18 21:00:02 +00:00
|
|
|
#include "../../extra.h"
|
2023-09-23 22:24:25 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#define ln lognormal_params
|
2023-11-18 21:10:21 +00:00
|
|
|
#define to(...) convert_ci_to_lognormal_params((ci)__VA_ARGS__)
|
|
|
|
#define from(...) convert_lognormal_params_to_ci((ln)__VA_ARGS__)
|
|
|
|
#define times(a, b) algebra_product_lognormals(a, b)
|
2023-09-23 22:24:25 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
// set randomness seed
|
|
|
|
uint64_t* seed = malloc(sizeof(uint64_t));
|
|
|
|
*seed = 1000; // xorshift can't start with 0
|
|
|
|
|
2023-11-18 21:10:21 +00:00
|
|
|
ln a = to({ .low = 1, .high = 10 });
|
|
|
|
ln b = to({ .low = 5, .high = 500 });
|
2023-09-23 22:24:25 +00:00
|
|
|
ln c = times(a, b);
|
|
|
|
|
|
|
|
printf("Result: to(%f, %f)\n", from(c).low, from(c).high);
|
|
|
|
printf("One sample from it is: %f\n", sample_lognormal(c.logmean, c.logstd, seed));
|
|
|
|
|
|
|
|
free(seed);
|
|
|
|
}
|