data structures – Binary Tree as 2D array with variable length raws

Usually we use the tree data structure when we care about time complexity for ins/del/…

-In this special case problem, space saving is mandatory too that is 2 pointers for each node is unaffordable; actual data are in leaves so infact even the internal nodes are considered overhead

-So, I thought of storing it as a 2D array with variable row size, we can assume the tree is almost always full complete power of 2, something like

R[0]= N leaf nodes

R[1]= N/2 level-1 nodes

R[2]= N/4 nodes

..
..

R[logN]= root

-I can derive the formulas for del/ins/… as the tree is easily mind-vewable from this presentation, without any pointers at all.

-Now, did I miss something???
-Is there any flaw in this?
-I’m checking for brainstorming or some opinions.

E(max{K-X, 0]) where X is a normally distributed variable?

I’m trying to find the $E(text{max}(K-X,0))$ where X is normally distributed random variable with mean $mu$ and standard deviation $sigma$. K is a constant.
Any help would be much appreciated!

plotting – Plot SinglePredictionBands associated with a FittedModel (e.g. LinearModelFit) that is supplied as a variable

I am puzzled about how to plot the SinglePredictionBands associated with a FittedModel (e.g. LinearModelFit) that is supplied as a variable.

The reasons I am interested in this are:

  • I want to create some plot definitions to reuse;
  • I want to include the graphics as arguments to Manipulate.

Please see the following code. The embedded comments explain what works and what doesn’t.

dataTest = {{0, 1}, {1, 0}, {3, 2}, {5, 4}};

(* Explicit code works:  both the fit and the bounds are plotted.  The name of the dummy variable doesn't matter here.  *)
lm = LinearModelFit(dataTest((1 ;; 3)), {xVar}, {xVar})
spb(xVar_) = lm("SinglePredictionBands")
Plot({lm(x), spb(x)}, {x, 0, 5}, PlotLabel -> "Explicit (argument x)")
Plot({lm(xVar), spb(xVar)}, {xVar, 0, 5}, PlotLabel -> "Explicit (argument xVar)")

(* This delayed-evaluation code either plots only the fit (with x) or nothing (with xVar). *)
lmFn1(aaa_, bbb_) := LinearModelFit(dataTest((aaa ;; bbb)), {xVar}, {xVar})
spbFn1(fit_)(xVar_) := fit("SinglePredictionBands")
Plot({lmFn1(1, 3)(x), spbFn1(lmFn1(1, 3))(x)}, {x, 0, 5}, PlotLabel -> "Delayed1 (argument x)")
Plot({lmFn1(1, 3)(xVar), spbFn1(lmFn1(1, 3))(xVar)}, {xVar, 0, 5}, PlotLabel -> "Delayed1 (argument xVar)")

(* This hybrid code either plots only the fit (with x) or only the bounds (with xVar). *)
Plot({lmFn1(1, 3)(x), spbFn1(lm)(x)}, {x, 0, 5},  PlotLabel -> "Delayed2 (argument x)")
Plot({lmFn1(1, 3)(xVar), spbFn1(lm)(xVar)}, {xVar, 0, 5},  PlotLabel -> "Delayed2 (argument xVar)")

(* I had also tried the following, although it would be inefficient, because fitting the same data is repeated.  *)
(* This alternative delayed-evaluation code either plots only the fit (with x) or nothing (with xVar).*)
pFn1(i_, j_) := Plot({lmFn1(i, j)(x), spbFn1(lmFn1(1, 3))(x)}, {x, 0, 5}, PlotLabel -> "Delayed3 (argument x)")
pFn2(i_, j_) := Plot({lmFn1(i, j)(xVar), spbFn1(lmFn1(1, 3))(xVar)}, {xVar, 0, 5}, PlotLabel -> "Delayed3 (argument xVar)")
pFn1(1, 3)
pFn2(1, 3)

Some of the problematic code generates errors like
LinearModelFit::ivar: {0.000102143} is not a valid variable.” (what’s visible is actually “LinearModelFit: {0.000102143} is not a valid variable.“), and some of it fails silently.

I’ve spent time trying many different configurations, and none worked. I’d appreciate an explanation of why the above-indicated lines of code don’t work, and how they could be improved (preferably a simple way to improve them).

As a final aside, I haven’t yet combined this with a Manipulate statement, but I am envisaging doing it with a subsequent Dynamic statement.

—DIV

P.S. After spending time debugging I did find a handful of posts on possibly related themes

But that was not sufficient to clarify to me what the underlying problem is, nor how to fix it.

python – Como modifico mi regex para que esta string quede dividida en 3 subtring, y cada una de ellas quede guardada en una variable

import re

input_text_to_check = "ElectrikVocal95#9525: what are we talking about?"
input_text_to_check = "ElectrikVocal95#9525: what are we talking about CPU?"
input_text_to_check = "ElectrikVocal95#9525: what are we talking about the planes?"

#Esta es la regex que tengo que cambiar
regex_patron = r"(.*)¿?(what are we talking about|what we were talking about | what we talked about before | what we talked about)s*(about|)s*((?:w+s*)+)?"

matches = re.search(regex_patron, input_text_to_check, re.IGNORECASE)

#guarda el nombre del hablante
#A = matches(1)
A = matches(1).replace(':', '')
print(A)

#guarda lo medio de la regex
B = matches(2)
print(B)

Necesito un C que guarde la palabra de lo que se hablo, osea lo que le sigue a lo que quedo almacenado en B, tambien C podria ser vacio “” en caso de que termine en B

La variable C tendría que sea igual a:

#guarda tema
C = ""
C = "CPU"
C = "the planes"

dependiendo del caso

derivatives – Proving the existence of a variable with given condition in a function

I came across a problem of fucntions which is as follows:
f is a differentiable function $${f: (0,(pi/2))rightarrow(0,1) }$$
such that f(0)=0, f$(pi/2)=1$ then; prove that $$f'(a)= (8a)/(pi) $$for at least one $a$ belonging to the domain.

I have tried using LMVT for the function between 0 and $(pi/2)$ but that does not seem to help as $a$ should appear in the derivative. I could assume the function as sin x but that does not give me a general solution of course. I have no other idea on how to solve it.

Any help would be greatly appreciated!

theming – How do I pass a node field variable into a layout builder section template?

So far what I understand is I need to start with this:

function mytheme_preprocess_layout__twocol_section

in my .theme file, but I’m not quite sure where to go from there.

For clarification, I have a term reference field on my content type. I’m trying to pass values from the term (specifically, an attached menu) into the layout builder section template so the node displays the correct menu depending on the taxonomy selected.

php – How to pass a variable into an add_filter() function?

I have this code here:

$pageLanguage = strtolower($pageMetadata("language")); 

$languageArray = array ("afrikaans" => "af", "dutch" => "nl", "french" => "fr", "german" => "de", "spanish" => "es"); 

$updatedLanguage = $languageArray($pageLanguage);

add_filter('locale', 'change_my_locale');
function change_my_locale( $locale ) {
  $locale = $updatedLanguage;
  return $locale;
}

I would like to know how to pass the variable $updatedLanguage into the change_my_locale() function please?

mysql – Is it possible to update a variable after using it (rather than before)?

@x=0
select
  case
    when col>1 then @x:=@x+1
    when col=1 then @x
    else @x; @x:=@x+1
  end as x
from t

I want to do something like what’s seen above in MySQL. The contents between the WHEN and THEN are arbitrary. However, what I want to do is seen after the ELSE statement. I know I can set a user variable where I can either output its value in the SELECT (by just using @x), or output some updated value (by using @x:=@x+1). What I want to do though is output the value @x, while also updating it @x:=@x+1. Is this possible?

theming – D9 – How to pass a node field variable into a layout builder section template?

So far what I understand is I need to start with this:

function mytheme_preprocess_layout__twocol_section

in my .theme file, but I’m not quite sure where to go from there.

For clarification, I have a term reference field on my content type. I’m trying to pass values from the term (specifically, an attached menu) into the layout builder section template so the node displays the correct menu depending on the taxonomy selected.

javascript – How to add a variable to a href tag as a parameter?

I have an interstitial page which has 6 identical links that depends on referralTokenValue to send traffic to a different site.

The link uses the following link structure:

<a href="https://example.com/program?referralToken=123456789">Link</a>

I’ve got a running prototype at: JSFiddle
However, I can’t use this prototype because it depends on the link ID attribute, which would not work 6 identical link IDs.

Because of this constraint, I’m looking for simple Javascript, without any dependencies on external CDN library(ies), where I can add the referralToken value to the Href tag, like so:

var referralTokenValue = 123456789;

I wanted to add the referraltokenValue to the href link tag, like so:

<a href="https://example.com/program?referralToken=referralTokenValue">Link</a>

The expected result would yield the following embedded link:

https://example.com/program?referralToken=12345789

How can add the referralTokenValue to the link without the dependency on the ID attribute?