From ea80c930e617c66b2bea71695dbb6df80cfd3d5e Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sun, 16 Jul 2023 21:52:24 +0200 Subject: [PATCH] reduce num samples, start README --- README.md | 38 +++++++++++++++++++ examples/04_sample_from_cdf_simple/example | Bin 22192 -> 22192 bytes examples/04_sample_from_cdf_simple/example.c | 2 +- examples/05_sample_from_cdf_beta/example | Bin 22176 -> 14204 bytes examples/05_sample_from_cdf_beta/example.c | 2 +- examples/05_sample_from_cdf_beta/makefile | 2 +- squiggle.c | 1 + to-do.md | 16 -------- 8 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 README.md delete mode 100644 to-do.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..a13492e --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# Squiggle.c + + + +## Why C? + +- Because it is fast +- Because it can be made faster if need be, e.g., with a multi-threading library like OpenMP +- Because if you can implement something in C, you can implement it anywhere else +- Because it will last long +- Because the language is honest +- Because I enjoy it + +## To do list + +- [ ] Have some more complicated & realistic example +- [ ] Add summarization functions, like mean, std, 90% ci (or all c.i.?) +- [ ] Add README + - Schema: a function which takes a sample and manipulates it, + - and at the end, an array of samples. + - Explain boxes + - Explain individual examples + - Explain nested functions +- [ ] Publish online + +## Done + +- [x] Add example for only one sample +- [x] Add example for many samples +- ~~[ ] Add a custom preprocessor to allow simple nested functions that don't rely on local scope?~~ +- [x] Use gcc extension to define functions nested inside main. +- [x] Chain various mixture functions +- [x] Add beta distribution + - See for a faster method. +- ~~[-] Use OpenMP for acceleration~~ +- [x] Add function to get sample when given a cdf +- [x] Don't have a single header file. +- [x] Structure project a bit better diff --git a/examples/04_sample_from_cdf_simple/example b/examples/04_sample_from_cdf_simple/example index 37f99c995c2b72506a88f0c7a7631c0a13973801..d280840081b9440e145852f4e89daf1d8b6c54c3 100755 GIT binary patch delta 53 zcmdn6mT?0RWiX4BO> #include -#define NUM_SAMPLES 1000000 +#define NUM_SAMPLES 10000 // Example cdf float cdf_uniform_0_1(float x) diff --git a/examples/05_sample_from_cdf_beta/example b/examples/05_sample_from_cdf_beta/example index 1ad5fec3996dfb9477adc1f8ea7c9f36f073abee..481e2d085132be87ea531397543dec0e4a616ece 100755 GIT binary patch literal 14204 zcmeHOeRP!7nSTQe1ZpzKmjOQ*t*n3&f=gX=Ynf0+hm|=?TX6$LlMp5lnoMG5a1q%E zi$fX4DD9d`x2>XEdvaWka;)bx?zS~RS|Ufgsd7BAQq3Z(??}3v0&Zjd$o_uMz4x6v zlVovE|J{3-x%c`0xX=A~-wgMMR^BqEpujP0jPoUjQ0JtepwzeHY`BnilvFJIj(DaG|C1?7}G@t2>hwN!D+k$$i`i|=qXnMy9 z2!e9-)!;j>s}j8F16rx+jocV5cYdL;JLeZFIny6fXvg#>zJ>L5>u*@RuztgW`nuSb ztqZm;xnaQ#i%a8;rB))ftm)|E6a%1thX}N(_}KU#3)XR%8yo*UjsJWe{wErLZ65wT zji*Ppo*Om(hCKZJ8h=wBzDVPj=HXw~_*?Su0gb;c58tBkU&+J!SS)B2_}G3<)cLtH z55I`aXf^oQ{1L%A&c-}^sm9ljg1=kvU%5WTN(@_WNRUr<8p0%V|4-% zZft0b=?qsoNOuGGwi`IAQ6n`sSL>-U`#8a?G;Xr)XQH>)>1@DP;)Cgx#^q3g&!zZW zBpAoxo^uI4+|y@i9J|lqbA^Vdq32%sSsM3wz0EjWmMpP}TCiC6>?Yyk$H(je7h^mf zpBeb%x63U=0AudsY@KCQ($jZ4?rsZjc*)pf;Te-@y%yf&inKnBXWkf>X|9Dgv641m z;Tel*gBISLYeHL8B^~vfJP=W6;TfB0lPx@DOe?YQdMgxCz{1;koonIE+)$v*!gGF1 zTVml^7p4U*JZs3bu*TDO)|+XoEPmFiX%!aU)Fo+E7T&JSO%~pqndEP>@T_suwpw_5 z{p_&tc5Uvl@T^hO_E~tlCih!-vt}rBz`~m~N_@M8XWg52$ij2&n$}_A0|tq{)53F| zo7QdN%^pEokH&Le^4Ie@{}q2+^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V1Y6MiF|?$fvzZMLc-&);Bi$LS8)IVsAz<$bVT0`PV4XLFr(s?xu%@|P z@%rn0co^17l}rJDL5e{dty67tlQ$d;;F(qvnV#}al~Lw73V1@^Ah>*uTxpRv)a-T9 z8(T)%X3bZUkKyQ5E{2*fOGoiH!_Zq-47KD5FB!~V%7Q}5TVxv9dtwayvx&W}+1r2) z&`W13ZiZl8Am|OZ`Rf!OIJM!Xwr~@Fv5Y~KHI*DPiXQROm{cC&nozUSj>v5Y)Q4uz z;_eRchmtfPUgl}l-bpmpiRLl(d)+&s>!PnNH zIO{e9(FCWVR$fDoh4CmhrQk(ftH04l0wUMa7*d>Uh@Hqf*EXX_nKpl|;tcuQQKXp$ z+|BH2arzs?+|p17ZL-95@JWVC$UK_zH3guIiz5&eCnmTiOj=`1y?+x#%N4dt*n9FM z?`I{I=P#m~@ya|=S{CT2L(0qhUP*1JGbVY?Au-zb8Re_7eo&Is&Wp)UxqeE39)=s` z<$biIHpwVxy8Lax@p!jc+Aq(QB$e%pG%tvVD2~E~z}X0t-t*oh&MMAxCFIQeNKYOX?7u(tgP&=|=~VB{02ADcg(1Qpvc z0diZD1!Nw@zfs;MXclO;A= z;j{xzX}?taRGPdzPmxrf-%9@U>*r}9FUMcrXGq#W#u-w2`@csWu}FD&J|pRIgDhp! z+dl%#C@;@(B+X6}kntnczJ&~a-oUOw!sLCte4k=Ezbs4oXUM1qd3kQFi5o)6N4hD= zvZQB$QS6FoFL}No-;XIBL)RZADJT8-AHb;pN%@HO4|G3AN&i;N)hQvOS6xRf_i89PSS;$mJ}Ee_o2 twvyVA_Q?5%s-^8*f`2|n3k%ZpwD^(j@>;sL8(aP #include -#define NUM_SAMPLES 1000000 +#define NUM_SAMPLES 10000 #define STOP_BETA 1.0e-8 #define TINY_BETA 1.0e-30 diff --git a/examples/05_sample_from_cdf_beta/makefile b/examples/05_sample_from_cdf_beta/makefile index 69adb6d..24c2c1c 100644 --- a/examples/05_sample_from_cdf_beta/makefile +++ b/examples/05_sample_from_cdf_beta/makefile @@ -5,7 +5,7 @@ # make run # Compiler -CC=gcc # required for nested functions +# CC=gcc # required for nested functions # CC=tcc # <= faster compilation # Main file diff --git a/squiggle.c b/squiggle.c index 560cd53..c68a14a 100644 --- a/squiggle.c +++ b/squiggle.c @@ -5,6 +5,7 @@ #include #include #include + #define EXIT_ON_ERROR 0 #define MAX_ERROR_LENGTH 500 #define PROCESS_ERROR(...) \ diff --git a/to-do.md b/to-do.md deleted file mode 100644 index 2eb1eb1..0000000 --- a/to-do.md +++ /dev/null @@ -1,16 +0,0 @@ - -- [x] Add example for only one sample -- [x] Add example for many samples -- ~~[ ] Add a custom preprocessor to allow simple nested functions that don't rely on local scope?~~ -- [x] Use gcc extension to define functions nested inside main. -- [x] Chain various mixture functions -- [ ] Have some more complicated & realistic example -- [ ] Add summarization functions, like mean, std, 90% ci (or all c.i.?) -- [x] Add beta distribution - - See for a faster method. -- [ ] Use OpenMP for acceleration -- [x] Add function to get sample when given a cdf -- [ ] Don't have a single header file. -- [ ] Structure project a bit better -- [ ] Add README -- [ ] Publish