Whaty could be the cause of postgres functions losing or swapping values from a CTE?

I have a number of functions which are generally in this shape:

RETURN QUERY with cte1 as (    select a, b, c, d, e    from [some_table]    where [some_condition] ), cte2 as (     select x, y, z     from [big_table]     where [bunch_of_conditions] ) select foo.x, foo.y, bar.a, bar.b, bar.c, bar.d from cte2 foo join cte1 bar on foo.z = bar.a 

I have seen occasions where the values of bar.b and bar.d are swapped, and on others no values are returned – upon investigation, because bar.a contains only nulls.

In all cases, when I take the code out of the functions, it always runs correctly. In each case where it goes wrong, there is nothing I can point to which causes the glitch, and usually it goes away for no obvious reason. This is all running in pgAdmin under Windows 10, and the behaviour persists through stopping pgAdmin, and/or rebooting the PC.

The db where this happens is running on AWS, and I don’t have access to stop/restart that server.

It suggests to me that the problem is happening at the AWS and/or postgres server end, but that may or may not be correct.

Possibly also relevant, we have also seen cases where queries run exceptionally slowly (45 minutes instead of less that one second, being one example today).

In each case of the swap or the slowdown, it eventually returns to normal behaviour without any obvious intervention from me. I’m still experiencing the null value which should be populated.

Has anyone seen behaviour like this? Any ideas what could be causing it, or how to remedy it?

Plot with three functions ana three parameters

i think my code doesn t have any problem but the program shows me this error and i comfused!/* Plot::argr: Plot called with 1 argument; 2 arguments are expected.*/

 a = 1; l = 2;     w1[x_, c_, theta1_] := x^c + theta1;     f[x_] := ( l^a*x^(a - 1)*Exp[-l*x])/Gamma[a];     mesi = Integrate[x*f[x], {x, 0, Infinity}];     mesi1 = Integrate[(x^c + theta1)*(( l^a*x^(a - 1)*Exp[-l*x])/Gamma[a]), {x, 0, Infinity}];     fw1[x_, c_, theta1_] := ((x^c + theta1)*(( l^a*x^(a - 1)*Exp[-l*x])/Gamma[a]))/(Integrate[(x^c + theta1)*(( l^a*x^(a - 1)*Exp[-l*x])/Gamma[a]), {x, 0, Infinity}]);     DH1[x_, c_,theta1_] := ((Integrate[(x^c + theta1)*(( l^a*x^(a - 1)*Exp[-l*x])/Gamma[a]), {x, 0,Infinity}])/((Integrate[(x^c + theta1)*(( l^a*x^(a - 1)*Exp[-l*x])/Gamma[a]), {x, 0, Infinity}]) +theta1))*(((x^c + theta1)*(( l^a*x^(a - 1)*Exp[-l*x])/ Gamma[a]))/(Integrate[(x^c + theta1)*(( l^a*x^(a - 1)*Exp[-l*x])/Gamma[a]), {x, 0, Infinity}])) + (theta1/ (Integrate[(x^c + theta1)*(( l^a*x^(a - 1)*Exp[-l*x])/Gamma[a]), {x, 0, Infinity}]) + theta1)*(( l^a*x^(a - 1)*Exp[-l*x])/Gamma[a]);  Manipulate[Plot[DH1[x, c, theta1]], {x, 0, 100}, , {c, 0, 10}, {theta1, 0, 10}]  /*my plot doesnt run ? i want to run this function with mean mesi */ 

Composition of functions and operator forms of built-in functions

I am trying to replicate the behaviour of some of the built-in operator forms (for Map, Apply etc) but struggling to understand the way Composition works. For a concrete example:

list = {1 \[UndirectedEdge] 10, 2 \[UndirectedEdge] 11, 3 \[UndirectedEdge] 11, 4 \[UndirectedEdge] 10}  Map[Apply[Rule]]@list  %: {1 -> 10, 2 -> 11, 3 -> 11, 4 -> 10} 

produces the result I was looking for in this case.

My question is how to replicate the composition of operator forms above. This naive attempt doesn’t work as intended and produces an error message:

Map@*Apply@*Rule@list 

Rule::argr: Rule called with 1 argument; 2 arguments are expected.

%: Map[Apply[Rule[{1 \[UndirectedEdge] 10, 2 \[UndirectedEdge] 11, 3 \[UndirectedEdge] 11, 4 \[UndirectedEdge] 10}]]] 

I’ve tried various combinations of parentheses to control the evaluation to avail – the example I started with appears to build an operator form of the composition of Apply and Rule then maps it over the list input but that is not what the composition I attempted does.

So, how to produce the same with Composition or other constructs?

I’m asking really to try and get a fuller understanding of these types of construction work.

Evaluation of a double summation invovlving hypergeometric and exponential functions

I am trying to compute the following double summation over the indices, $ m$ and $ n$ , which involves the hypergeometric function, $ {}_2 F_1$ , an exponential function and, factorials as a part of a bigger calculation.

Here’s the code.

Sum[((E^(-0.6931471805599453` m - 0.6931471805599453` n -    1.0000000000000002` \[Beta]^2) \[Beta]^(2 m)   c[n,n1,p]^2 r! Hypergeometric2F1[-n, -m - n + r,    1 - n + r, -1]^2)/(n! (m + n - r)! ((-n + r)!)^2)), {m, 0, \[Infinity]}, {n, 0, \[Infinity]}] 

where c[n_, n1_, p_] := n1!/(n! (n1 - n)!) p^n (1 - p)^(n1 - n) is the binomial distribution.

Any guidance on how to go proceed with this summation (either numerically or analytically) would be really appreciated.

NArgMin with Root functions

I’m trying to minimize an error function sumt to find some parameters S, s0, si :

Ris[S_?NumericQ, s0_?NumericQ, si_?NumericQ, so_?NumericQ, R_?NumericQ] =   RR /. Solve[((8 RR*S ((2 RR^2)/R^3 - s0))/R^3 +         8 \[Pi] RR si + (8 \[Pi] RR^2 so)/(R^3 + RR^3)^(        1/3)) == 0, RR][[4]] ri = {54, 55, 62, 66, 62, 66, 71, 75, 77, 79, 94, 89, 99, 113, 124,    123, 140, 157, 163, 176} re = {72, 74, 82, 83, 90, 97, 104, 113, 115, 126, 136, 143, 158, 171,    185, 192, 218, 226, 246, 270} Rdata = (re^3 - ri^3)^(1/3); tableerror =    Table[(Ris[10^S, s0, si, 1, Rdata[[i]]] -        rayoninterne[[i]])^2, {i, 1, Length[rayoninterne]}]; sumt[S_?NumericQ, s0_?NumericQ, si_?NumericQ] =    Total[tableerror]; NArgMin[{sumt[S, s0, si],    8 < S < 11 && 0.001 < s0 < 0.1 && 0.001 < si < 10}, {S, s0, si}] 

But this doesn’t work and I suspect that it is because the Root function in my Ris function. Is it the issue ? And how could I fix this ?

Modifying a CoBlocks Filter in Functions

I’m trying to modify slidestoshow parameter in CoBlocks Carousel block via my theme’s functions. Everything in the Codex implies modifying/passing the variable but looking at the code, it appears it’s an [anonymous function?] Forgive me if this term is incorrect.

I’ve tried both apply_filters() and add_filters() to replace the entire array rather than the individual key/value. I’ve tried removing the existing filter and adding it again but I’m not sure if the way it’s coded is preventing me from making my modification.

Do I need to call the plugin Class CoBlocks_Settings?

Here is the original plugin code:

$  block_content = sprintf( '<div class="%1$  s"><div class="coblocks-slick pb-8" data-slick="%2$  s">',     esc_attr( $  class ),     esc_attr(         wp_json_encode(             /**              * Filter the slick slider carousel settings              *              * @var array Slick slider settings.             */             (array) apply_filters(                 'coblocks_post_carousel_settings',                     array(                     'slidesToScroll' => 1,                     'arrow'          => true,                     'slidesToShow'   => $  attributes['columns'],                     'infinite'       => true,                     'adaptiveHeight' => false,                     'draggable'      => true,                     'responsive'     => array(                         array(                             'breakpoint' => 1024,                             'settings'   => array(                                 'slidesToShow' => 3,                             ),                         ),                         array(                             'breakpoint' => 600,                             'settings'   => array(                                 'slidesToShow' => 2,                             ),                         ),                         array(                             'breakpoint' => 480,                             'settings'   => array(                                 'slidesToShow' => 1,                             ),                         ),                     ),                 )             )         )     ) ); 

First, I tried just overriding it with:

apply_filters( 'coblocks_post_carousel_settings',  array( ... )); 

Second, here’s where I’m at in Functions:

apply_filters( 'coblocks_post_carousel_settings', 'my_filter_coblocks_carousel' ); function my_filter_coblocks_carousel() {     $  carousel = array(         'slidesToScroll' => 1,         'arrow'          => true,         'slidesToShow'   => $  attributes['columns'],         'infinite'       => true,         'adaptiveHeight' => false,         'draggable'      => true,         'responsive'     => array(             array(                 'breakpoint' => 1024,                 'settings'   => array(                     'slidesToShow' => 4,                 ),             ),             array(                 'breakpoint' => 600,                 'settings'   => array(                     'slidesToShow' => 4,                 ),             ),             array(                 'breakpoint' => 480,                 'settings'   => array(                     'slidesToShow' => 4,                 ),             ),         ),     );     return $  carousel; }  

How to count in relational algebra without aggregate functions?


Find the user who has liked the most posts. Report the user’s id, name and email, and the id of the posts they have liked. If there is a tie, report them all.

The schema:

User(uid, name, website, about, email, phone, photo)  Likes(liker, pid, when)  Likes[liker]  is contained in  User[uid] 

I think I need a "function" NumberOfLikes or similar where I can do something like:

enter image description here

We aren’t allowed to use aggregate functions in this exercise. I assume the way to count in RA is by performing some sort of cross product black magic, but I don’t know how.

Help?

Numerical issues in Fourier transform of Mathieu functions

I’m trying to calculate the Fourier transform of the Mathieu $ \text{me}$ functions using NIntegrate but keep on getting NIntegrate::inumr (the integrand has evaluated to non-numerical values) and NIntegrate:ncvb (failed to converge to prescribed accuracy) errors. Here is how I’m defining the Mathieu functions

ce[r_, z_, q_] := MathieuC[MathieuCharacteristicA[r, q], q, z] se[r_, z_, q_] := MathieuS[MathieuCharacteristicB[r, q], q, z] me[r_, z_, q_] := (ce[r, z, q] + I se[r, z, q]) / Sqrt[2 Pi] 

and I’m evaluating the integral

NIntegrate[Exp[-I n z] / Sqrt[2 Pi] me[r, z, q], {z, 0, 2 Pi}] 

where r is very close to an integer (I avoid exact integers because MathieuCharaceristicA and MathieuCharaceteristicB are not continuous at integers) and q for example varies continuously from -70 to 0.

Does anyone know how I can get around the numerical issues? Or is there a more efficient way to numerically Fourier transform Mathieu functions?