🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel! Set by lizmat on 6 September 2022. |
|||
00:06
Guest75 joined
00:07
Guest75 left
00:41
Guest75 joined
00:45
Guest75 left
00:47
Guest75 joined
00:50
Guest75 left
01:30
kylese left,
kylese joined
|
|||
scullucs | Can I get arbitrary precision floating-point calculations, well, let's say, something like 30 digits after the point for example? | 01:38 | |
02:15
kylese left,
kylese joined
|
|||
MasterDuke | scullucs: arbitrary, but fixed to a specified precision? not in core. but if you just mean arbitrary, FatRat might be what you want | 02:20 | |
scullucs | Hmm... I suppose rationals could do, yeah. | 02:21 | |
I said arbitrary, but fixed to some precision, because I don't think asking for all the decimals of an irrational is a rational demand 🙂 | 02:24 | ||
jdv | the rats in nyc can be pretty fat sometimes | ||
scullucs | But yeah, it turns out that FatRat`s will work out in my use case. | ||
02:49
MasterDuke left
03:00
MasterDuke joined
04:04
Aedil joined
04:09
guifa left,
thaewrapt left
04:10
guifa joined
04:24
thaewrapt joined
04:31
thaewrapt left,
thaewrapt joined
04:32
MasterDuke left
05:04
guifa left
05:10
Aedil left
05:30
Sgeo_ left
05:36
Aedil joined
06:01
thaewrapt left
06:02
thaewrapt joined
06:17
doomslord joined
|
|||
doomslord | scullucs: what you need a FatRat for that an Int cannot provide? | 06:18 | |
06:24
CIAvash joined
|
|||
doomslord | I mean: Integers don’t have denominators, but also as soon as you are relying on an exponential complex algorithm such as integer factorization to run your code, you are doomed | 06:24 | |
If you have only one denominator, Ints are as good as FatRats | 06:25 | ||
Just don’t do it: never use FatRats | 06:26 | ||
If you need FatRats, there is probably a better solution | 06:27 | ||
06:28
doomslord left
06:36
doomslord joined
|
|||
doomslord | The IBM POWER9 and the IBM z/Architecture support quadruple precision floating point (30 significant digits) in hardware | 06:36 | |
06:38
CIAvash left
|
|||
doomslord | Although in wouldn’t advice to buy them hahaha | 06:43 | |
06:43
doomslord left
07:16
sena_kun joined
07:20
CIAvash joined
07:32
sena_kun left
07:33
CIAvash left
|
|||
librasteve | doomslord: i am sympathetic to your cause, but do you mean <doomslord> If you have only one denominator, Ints ^h^h^h Rats are as good as FatRats ??? | 07:56 | |
tellable6 | librasteve, I'll pass your message to doomslord | ||
librasteve | otherwise i don’t understand where the denominator lives… | 07:57 | |
lucs: simplistically I would have said that FatRats are for you … but in “nanny” mode would urge you to think twice about your problem … 30 digits after the point is a very small number … way too small for anything physical | 08:02 | ||
lemire.me/blog/2020/03/15/number-o...nt-values/ | |||
even in pure math there are many algorithms that become unstable with such small values | 08:04 | ||
en.wikipedia.org/wiki/Numerical_stability | 08:05 | ||
08:05
donaldh left
|
|||
anyway since you are a rakoon, then I am sure you have good reasons and know all this | 08:07 | ||
apologies for my intrusion | 08:08 | ||
scullucs | I'm simulating a mathematical process where values can be pretty close to, but greater than, zero. | 08:19 | |
Luckily, it turns out that FatRats appear to work fast enough for what I'm doing. | 08:20 | ||
So the numbers I wanted to represent were something like 0.000000000000000000000001. | 08:24 | ||
(and its multiples) | 08:26 | ||
librasteve | my first coding job was to write tests for an FPU in C … I can say with some confidence that you are not going to be able to get what you want from a regular FPU .. so some kind of integer based library like FatRat or maybe there is a C / perl / python library that you can wrap | 08:37 | |
scullucs | Yep, FatRat appears to have worked (although I'm not sure I understand the results I'm getting). | 08:40 | |
Let me show you the thing I'm trying to simulate. | |||
It's a puzzle that Cliff Pickover posted on Twitter. | 08:41 | ||
: A mathematician emerges from a cave and says "I have cracked 10,000 rods at random into 2 pieces by throwing them against a rock. What do you think is the average ratio of the length of the long piece to the length of the short piece?" | 08:42 | ||
I'm not knowledgeable enough to solve this with math, so I was curious to see what simulating the action would give. | 08:43 | ||
librasteve | .oO | 08:44 | |
me neither … i recall that some probability problems have pi (or may pi / 4) as a solution | 08:45 | ||
reaches for ChatGPT… | 08:47 | ||
perplexity.ai gave me a pretty good explanation … | 08:49 | ||
scullucs | Is an answer possible? | 08:50 | |
(according to that?) | |||
08:57
El_Che left
08:58
El_Che joined
09:30
dawids joined
09:31
dawids left
09:56
nine left,
nine joined
|
|||
librasteve | well - that would be a spoiler! I think the approach is good - which is (look away now) to understand that "stick breaks at random point" means that "if the stick is 100 units long, there is a 1/100 chance it will break at the midpoint (50/50) and a 1/100 chance at 49/51 and so on" - then its just a (very thorny) summation / integration - but there is a clear solution | 10:28 | |
Xliff | Well, that beats my approach. | 10:30 | |
for ^10000 { my $a = rand; [/]( |[ $a, 1 - $a ] ).sort; }; @a.sum / @a.elems } | |||
I'm then doing that another 10000 times. Don't mind me. No sleep. Frustrated. Can't find my proper pair of glasses and I figured I'd hack together the most idiotic brute force algorithm ever. | 10:31 | ||
And I forgot to use a FatRat.... that might explain why it hasn't finished. | 10:32 | ||
10:45
Guest75 joined
11:00
Guest75 left
11:02
merp left
11:03
Guest75 joined
11:13
[Coke] left
11:16
[Coke] joined
11:38
Guest75 left
11:47
tai_aowex joined
11:50
thaewrapt left
12:03
xinming left,
xinming joined,
tai_aowex is now known as thaewrapt
|
|||
[Coke] returns to his normally scheduled routine. Hio. | 12:51 | ||
13:08
jgaz joined
|
|||
lizmat | and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2024/08/26/2024-...ro-💍-htmx/ | 13:29 | |
13:54
thaewrapt left
|
|||
antononcube | @lucs and @librasteve I think you are doing it wrong! 😛 | 13:57 | |
14:05
thaewrapt joined
|
|||
Questions to consider: 1. Is the mathematician right handed or left handed? 2. Where the rock is located wrt to the mathematician? (Distance and direction.) 3. What are the size and shape of the rock? 4. Does the mathematician miss? 5. Is the rock flat or has sharp edge? (Edge which the mathematician aims at and reliably hit.) 6. How do the rods hit the rock? (Completely "flat" along the long side, on the one | 14:06 | ||
small sides, anywhere in between.) 7. What is the shape of the rods? 8. Do the rods break when hitting the rock? More generally, what is the strength of rod's material wrt to the rock? 9. Does the rock break, and is it replaced another one? Same/similarly shaped or at random? 10. If a rod breaks is only in two parts? Do we measure the ratio of the two longest parts? 11. Are the rods all the same? 12. Etc. | |||
Coming up with these kind of questions, choosing which of them to answer, and examining the answers, can help selecting, say, probabilistic models for the processes considered. | 14:08 | ||
At that point -- for these kind of problems -- it is essential to have an extensive library with different probability / statistical distributions with which lists of random variates can be generated. | 14:10 | ||
For example, see here: github.com/antononcube/Raku-Statis...rakumod#L8 | 14:11 | ||
As for the FatRat's -- they can happen "naturally" when doing certain recursive mathematical formulas, e.g. Chebyshev polynomials. I compared Raku's results with those Mathematica -- complete agreement on the FatRat / BigNum results. | 14:13 | ||
use Math::Polynomial::Chebyshev; my $v = chebyshev-t(100, <1/4>.FatRat, method => 'recursive') | 14:15 | ||
cdn.discordapp.com/attachments/633...00eee& | |||
scullucs | Welp, that's pretty much what I did. | 14:23 | |
14:24
Guest75 joined
|
|||
Oh! reading... | 14:24 | ||
14:24
thaewrapt left
|
|||
@antononcube So many things I didn't consider! 🙂 | 14:25 | ||
antononcube | @lucs Interesting problem to tackle with Raku, for sure. Made me notice a bug "Statistics::Distributions" (fixed now.) | 14:34 | |
14:35
thaewrapt joined
14:40
thaewrapt left
14:51
thaewrapt joined
14:56
thaewrapt left
15:07
thaewrapt joined
15:10
Guest75 left
|
|||
@scullucs Damn! I thinking too much about this problem now! 🙂 | 15:13 | ||
scullucs | Sorry! 😂 | ||
15:14
thaewrapt left
|
|||
lizmat | antononcube would you have any ideas about integrating LLM features into the Raku documentation website docs.raku.org ? | 15:23 | |
15:24
thaewrapt joined
|
|||
[Coke] | I have no desire to include non-core LLM stuff on the docs site. | 15:24 | |
15:33
thaewrapt left
15:43
thaewrapt joined
15:49
thaewrapt left
16:00
thaewrapt joined,
xinming left
16:01
xinming joined
16:09
dawids joined,
thaewrapt left
16:15
thaewrapt joined
|
|||
antononcube | @lizmat Sorry, @Coke is back to their "normally scheduled routine", so, we missed our chance for "LLMs-in-the-docs." 😭 | 16:22 | |
lizmat | antononcube I think [Coke]'s emphasis was on non-core | 16:23 | |
16:24
thaewrapt left
|
|||
scullucs | @antononcube At first, I thought you were joking with those "Questions to consider". | 16:32 | |
16:32
thaewrapt joined
|
|||
But from what you showed me in direct message I see that you were serious, and that those questions should perhaps be addressed to get a comprehensive solution. | 16:32 | ||
I was trying to solve a very limited version which might be stated as: "If a line segment is separated in two parts at some random point, excluding the endpoints, on average, what is the ratio of the length of the longer part to the shorter one?" | |||
So I think that, and very respectfully, you know too much! | |||
"If the tools you have include a hammer, a screwdriver, a shovel, a vise grip, a wrench, a saw, reverse pliers, and a cable stripper, you tend to see every problem as a weekend project." 🙂 | |||
[Coke] | Yah, happy to discuss docs in general, but docs.raku.org is, in my mind, primarily for language spec (with some allowance for only having one implementation) | 16:34 | |
antononcube | @lizmat Hmm... not-sure what that means. ("non-core LLM functionalities.") | 16:39 | |
[Coke] | any raku LLM stuff is outside of core. No? | 16:40 | |
antononcube | For what is worth here is what I think it is need for a really "strong" LLM presence in Raku (i.e. few things have to be figured out): 1. Streamlined and easy way of including new LLM service providers. 1.1. Right now there are five LLM-services packages: "WWW::OpenAI", "WWW::PaLM", "WWW::MistralAI", "WWW::Gemini", "WWW::LLaMA" 1.2. But at least another four or five LLM-services are (or becoming) popular: | ||
Anthropic, AlephAlpha, Cohere, DeepSeek, Groq, TogetherAI. 1.2.1. I have not looked into their interfaces -- maybe they are similar to that of OpenAI. (If yes, corresponding packages can be easily made.) 1.2.2. I have an experimental LLM project for making Raku packages from LLM-access API documentation, but it is a low priority for now. 1.2.3. Maybe there is much more streamlined or easy way than making a Raku package for | |||
every LLM-service. 2. Better documentation of LLM-access configurations. 2.1. That is "easy", but it is only outlined how to do "LLM::Functions". 3. Easy utilization of (i) user made/specified prompts, and (ii) prompts from the Web. 3.1. Usage of user prompts has been supported from the very beginning of my LLM projects. 3.2. Inclusion of user defined prompts into a local database is supported, but has to be documented better. | |||
3.2.1. And probably, easier to do. 3.3. Usage and inclusion of "any prompt found in the Web" is something I have considered for a long time. 3.3.1. Something like llm-resource-function. 3.3.2. Never got a good implementation design for it. | |||
16:41
sena_kun joined
|
|||
lizmat | afk for a few hours& | 16:43 | |
antononcube | 4. Some sort of curated and central for the Raku community repository of prompts, in which anyone can contribute. (And review.) 4.1. I am not sure is this a good idea. 4.2. It is less important if 3.3 above is implemented. | 16:44 | |
16:44
dawids left
|
|||
@Coke Yes -- LLM functionalities are out of the core. | 16:44 | ||
But Raku's LLM functionalities can be featured in the section/page similar to "Doing math with Raku", docs.raku.org/language/math . | 16:46 | ||
I.e. "Doing LLMs with Raku" of similar. | |||
BTW, I consider the section name "Numerical integration of ordinary differential equations" misleading. (docs.raku.org/language/math#Numeri...quations). It should be "Numerical solution of ordinary differential equations." | 16:48 | ||
I know that "numerical integration" is used a lot to refer to solutions of differential equations, but it is misleading, since one might think that Raku can compute integrals. | 16:49 | ||
(Another project I really should get back to: "Math::NIntegrate".) | 16:50 | ||
@lucs Fine, let me write a oneliner that uses the Beta Distribution or the Truncated Normal Distribution. | 16:53 | ||
scullucs | I don't know what that means, I'm really ignorant 😦 | 16:58 | |
But I suspect that one interesting intuitive way of looking at the problem is that the a typical thrown rock will be closer to the center than the edge, that is, the randomly chosen points should appear more frequently near the center -- I guess there is typical distribution that can represent something like that. | 17:01 | ||
antononcube | Yes, with "typical distribution" I think you mean "Normal Distribution". | ||
scullucs | I guess, yeah. Does that make sense? | 17:02 | |
antononcube | The distribution selection plays a great role. | 17:09 | |
scullucs | I think that how close to the edge a point can be chosen can also make the average increase. | 17:12 | |
antononcube | @lucs Here is a "short mode", which I did not make a one liner since the steps are didactic: my $n = 10_000; my @trials = random-variate(NormalDistribution.new(1/2,1/5), $n).grep(0≤*≤1); @trials.map({ my $a = 1-$_; $_ > $a ?? $_ / $a !! $a / $_ }).sum / @trials.elems | ||
Note that the code above uses less than 10_000 trials to compute the ratios. (I seems that the misfirings are less than 2%.) | 17:13 | ||
It is very instructive to plot the histogram of the trials. The easiest way to do that is to use "Text::Plot": use Text::Plot; text-histogram(@trials, height=>20, x-limit=>(0,1)) | 17:16 | ||
scullucs | @antononcube Thanks for the code. | 17:31 | |
17:35
silug1 joined
17:38
silug left,
silug1 is now known as silug
18:51
dawids joined
19:29
Aedil left
19:43
bingos is now known as BinGOs
21:04
jgaz left
|
|||
antononcube | .release6 | 21:37 | |
releasable6: status | |||
releasable6 | antononcube, Next release in ≈2 days and ≈21 hours. There are no known blockers. Changelog for this release was not started yet | ||
antononcube, Details: gist.github.com/34b1d7f2a92dad8d0e...27285b08db | |||
21:49
guifa joined
22:07
dawids left
22:30
Sgeo joined
22:36
guifa left
22:57
sena_kun left
23:11
guifa joined
|