본문 바로가기
통계프로그램 비교 시리즈/오라클함수 비교(R & Python)

TANH 오라클 함수 [Oracle, Pandas, R Prog, Dplyr, Sqldf, Pandasql, Data.Table, DuckDB]

by 기서무나구물 2021. 12. 22.

포스팅 목차

    * 파이썬 & R 패키지 호출 및 예제 데이터 생성 링크


    [ TANH Oracle Function ]

     


    TANH함수는 지정한 인수 n의 쌍곡선 탄젠트(hyperbolic tangent)를 반환한다.

     

     

     


    1. Oracle(오라클)

     

    TANH() 함수

     

    Oracle Programming
    SELECT TANH(.5) "Hyperbolic tangent of .5" 
    FROM   DUAL;

     

    Results
             Hyperbolic tangent of .5
    ------------------------------------------
    .462117157260009758502318483643672548721

     


    2. Python Pandas(파이썬)

     

    math.tanh() 함수

     

    Python Programming
    import math
    math.tanh(.5)

     

    Results
    0.46211715726000974

     

     

     


    3. R Programming (R Package)

     

    TANH() 함수

     

    R Programming
    %%R
    
    tanh(.5)

     

    Results
    [1] 0.4621172

     

     

     


    4. R Dplyr Package

     

    TANH() 함수

     

    R Programming
    %%R
    
    emp %>%
      dplyr::mutate(tanh_value = tanh(deptno/10)) %>%
      head()

     

    Results
    # A tibble: 6 x 9
      empno ename  job        mgr hiredate     sal  comm deptno tanh_value
      <dbl> <chr>  <chr>    <dbl> <date>     <dbl> <dbl>  <dbl>      <dbl>
    1  7369 SMITH  CLERK     7902 1980-12-17   800    NA     20      0.964
    2  7499 ALLEN  SALESMAN  7698 1981-02-20  1600   300     30      0.995
    3  7521 WARD   SALESMAN  7698 1981-02-22  1250   500     30      0.995
    4  7566 JONES  MANAGER   7839 1981-04-02  2975    NA     20      0.964
    5  7654 MARTIN SALESMAN  7698 1981-09-28  1250  1400     30      0.995
    6  7698 BLAKE  MANAGER   7839 1981-03-01  2850    NA     30      0.995

     

     

     


    5. R sqldf Package

     

    TANH() 함수

     

    R Programming
    %%R
    
    sqldf(" select tanh(.5) tanh_val ")

     

     

     


    6. Python pandasql Package

     

    TANH() 함수

     

    Python Programming
    ps.sqldf(" SELECT tanh(.5) tanh_val ")

     

     

     


    7. R data.table Package

     

    TANH() 함수

     

    R Programming
    %%R
    
    DT          <- data.table(emp)
    dept_DT     <- data.table(dept)
    
    DT[,tanh_value := tanh(deptno/10)][1:10, ]

     

    Results
        empno  ename       job  mgr   hiredate  sal comm deptno tanh_value
     1:  7369  SMITH     CLERK 7902 1980-12-17  800   NA     20  0.9640276
     2:  7499  ALLEN  SALESMAN 7698 1981-02-20 1600  300     30  0.9950548
     3:  7521   WARD  SALESMAN 7698 1981-02-22 1250  500     30  0.9950548
     4:  7566  JONES   MANAGER 7839 1981-04-02 2975   NA     20  0.9640276
     5:  7654 MARTIN  SALESMAN 7698 1981-09-28 1250 1400     30  0.9950548
     6:  7698  BLAKE   MANAGER 7839 1981-03-01 2850   NA     30  0.9950548
     7:  7782  CLARK   MANAGER 7839 1981-01-09 2450   NA     10  0.7615942
     8:  7788  SCOTT   ANALYST 7566 1982-12-09 3000   NA     20  0.9640276
     9:  7839   KING PRESIDENT   NA 1981-11-17 5000   NA     10  0.7615942
    10:  7844 TURNER  SALESMAN 7698 1981-09-08 1500    0     30  0.9950548

     


    8. Python Duckdb의 SQL

     

    Python Programming
    %%sql
      select ((exp((0.5 * 2)) - 1) / (exp((0.5 * 2)) + 1)) As Tanh_func

     

     

    Python Programming
    duckdb.sql(" select ((exp((0.5 * 2)) - 1) / (exp((0.5 * 2)) + 1)) As Tanh_func ").df()

     

     

    Results
       Tanh_func
    0   0.462117

     


    Pencil on system of equations ( https://unsplash.com/photos/_zsL306fDck )

      --------------------------------------------  

     

     

    [Oracle, Pandas, R Prog, Dplyr, Sqldf, Pandasql, Data.Table] 오라클 함수와 R & Python 비교 사전 목록 링크

     

    오라클 SQL 함수(Oracle SQL Function) 목록 리스트 링크

     

    [SQL, Pandas, R Prog, Dplyr, SQLDF, PANDASQL, DATA.TABLE] SQL EMP 예제로 만나는 테이블 데이터 처리 방법 리스트 링크 링크
    반응형

    댓글