a method of calculating the power of a scale

Asked 2 months ago, Updated 2 months ago, 6 views

What I want to do in the end is
I want to make a table of normal distribution cumulative functions

In order to do this, Error function must be calculated. There's a factorial calculation in it, but it's not in the MySQL math function

If it's a program,

retval=1
for in 1..n
  retval*=i

I think it's easy to write, but how is it faster (speed and source) to write in MySQL?

Generate tables from 1 to N and then
exp(sum(log(n)))
I've seen articles like taking , but log and exp seem to be much heavier than integer operations, so I don't think it's worth it

Do we have no choice but to obtain data from the program side and calculate it on the program side?

Supplement:

This is MySQL 5.7

Add

Write down the details of what you want to do

for tens of thousands of normal distributed records with mean and distributed columns Calculate where the current time is in the cumulative distribution
I would like Lambda to take action to retrieve only records in a specific location

I'm thinking of using the formula "To calculate this repeatedly, it's easy to formulate as follows" from the wiki (I can't paste it because it's SVG).

The outer side is sum, but the inner loop is actually graded, so I asked you how to write it.

There is also an approximation, but I didn't understand the meaning of "at least decimal and single digit accuracy for the error function near the real axis," and I used eye-fuku calculations because only a few first sections were required to converge faster than Taylor's.

The required accuracy is about 1/24 x 3600 because the horizontal axis is the daily distribution and the precision is sufficient in seconds.
Can the approximate expression satisfy this accuracy?

The expression itself is complicated, but based on the above accuracy requirements, it is a light process that does not actually have 100 operations
There are only a few data to be retrieved each time, so
I thought it would be more beneficial to do it on the MySQL side than using network overhead

mysql

2022-09-30 14:19

1 Answers

This is the SQL for the power of the power. I tried the mysql8.0.18.0 32-bit version.
As metropolis commented, 21 was an error.

[email protected]:=20;
select f
from(
    with recursive rc(f, i)as(
    select1,@n
    union all
    select f*i, i-1
      from rc
     where i-1>=0)
    select f, i from rc
as a
where i = 1
;
2432902008176640000

I understand that the answer is different from what KTI wanted to solve, but
I'm going to answer because I think it might be helpful to write recursive SQL using the with clause.


2022-09-30 14:19

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.