Probability that one random variable is greater than another

Suppose I have two random variables:

Control = BetaDistribution[24,141] Var = BetaDistribution[30,151] 

I can sample from this easy enough with RandomVariate[Var, 10] and calculate the probability that one of the distributions is greater than a constant, e.g. Probability[x <= .2, x \[Distributed] Var].

But how do I calculate $ P(Var>Control)$ . Many thanks!

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?

Manipulating an equation to isolate a term (not solve for a variable)

Consider the following minimal example of my problem:

eq = (a^2 + a == b^2) 

I would like to manipulate this equation to achieve:

a == b^2 - a^2 

First, note the obvious point that solving for a in this context is not appropriate as

Solve[eq, a] 

solves the quadratic equation, which is not my goal.

Alternatively, there are rather straightforward ways by which one can rearrange this equation by hand, for example:

AddSides[eq, -a^2] 

But that requires "human insight" and is awkward indeed for my full problem (where there are many terms on both sides of the equation).

For obvious and analogous reasons, Gather does not solve this problem either.

One can go in by hand and identify the desired term and manipulate the equation, basically by hand but that is of little help.

My presenting case is an enormous reduced equation in many variables that contains (say) a single a amidst many terms on the left. I’m seeking the simplest way to compute an equation of the form a == ......... which may (indeed does) contain nonlinear terms involving a on the right. I’m seeking the re-arranged equation so I can perform additional manipulations (with other equations and such).

Suggestions?

On a multisite environment, get the subdomain value as variable

I’m trying to setup a multisite where everytime a new site is added, a DNS record is also added in Cloudflare. So far, the code is working but I’m having troubles trying to parse the subdomain value onto a variable.

This is the code so far:

function create_cloudflare_dns_record() {  //$  current_site = ''.$  get_blog_details->siteurl.''; //$  current_site = ''.$  substr( $  current_site, -8).''; //$  current_site = ''.explode('.', $  current_site).'';   /* Cloudflare.com | APİv4 | Api Ayarları */ $  apikey     = '778***************************c37'; // Cloudflare Global API $  email      = 'al******@***********.com'; // Cloudflare Email Adress $  domain     = 'mer*****.com';  // zone_name // Cloudflare Domain Name $  zoneid     = 'ecc**********************1e1'; // zone_id // Cloudflare Domain Zone ID //$  current_site   = ''.$  get_sites->path.''; $  current_site = explode('.', $  _SERVER['HTTP_HOST']);   // $  _SERVER['HTTP_HOST']  // A-record oluşturur DNS sistemi için. $  ch = curl_init("https://api.cloudflare.com/client/v4/zones/".$  zoneid."/dns_records"); curl_setopt($  ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($  ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($  ch, CURLOPT_SSL_VERIFYPEER,false); curl_setopt($  ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($  ch, CURLOPT_HTTPHEADER, array( 'X-Auth-Email: '.$  email.'', 'X-Auth-Key: '.$  apikey.'', 'Cache-Control: no-cache', // 'Content-Type: multipart/form-data; charset=utf-8', 'Content-Type:application/json', 'purge_everything: true'  ));  // -d curl parametresi. $  data = array(      'type' => 'CNAME',     'name' => ''.$  current_site.'',     'content' => 'mer***.com',     'zone_name' => ''.$  domain.'',     'zone_id' => ''.$  zoneid.'',     'proxied' => true,     'ttl' => '120' );  $  data_string = json_encode($  data);  curl_setopt($  ch, CURLOPT_POST, true); curl_setopt($  ch, CURLOPT_POSTFIELDS, $  data_string); //curl_setopt($  ch, CURLOPT_POSTFIELDS, http_build_query($  data_string));  $  sonuc = curl_exec($  ch);  /*     //print_r($  sonuc); */  curl_close($  ch);    }   add_action( 'wp_insert_site', 'create_cloudflare_dns_record' ); 

None of the three different attempts for $ current_site at the beggining of the function is giving any result.

If I manually replace the value for $ current_site, the code is working.

Any help is greatly appreciated.

Creating new variable names, Symbol or ToExpression

One can create new variable names by Symbol :

In[1]  Table[Symbol["x"<>ToString[i]], {i,1,5}] Out[1]  {x1,x2,x3,x4,x5} 

But it is also possible to use ToExpression (old firend) :

In[2]  Table[ToExpression["x"<>ToString[i]], {i,1,5}] Out[2]  {x1,x2,x3,x4,x5} 

There is a difference : Symbol will produce an error for incorrect varialbe names while ToExpression will do something meaningful.

In[3]  Table[Symbol[ToString[i]<>"x"], {i,1,5}] Out[3]  (* some error message with non-helpful output)  In[4]  Table[ToExpression[ToString[i]<>"x"], {i,1,5}] Out[4]  {x,2x,3x,4x,5x} 

Other than this, I see there is no difference. Is there a situation such that Symbol is more useful than ToExpression ?

How does a PackedScene work when passed in an exported variable

To my beginner understanding, in order to use a scene saved on the drive, one must first use ResourceLoader.load() to load the scene to acquire a PackedScene, then instantiate it using PackedScene.instance() to acquire the Node that can be finally added as a child.

Following this principle, one can easily export a script String variable and use it to set which scene will be loaded by a node – even with convenient hints like this:

export(String, FILE, "*.tscn") var scene_path 

But that’s not fully descriptive in my opinion. I want to select a scene – an only scene – in that exported variable. Looking around the internet, this Godot Q&A post mentions one can export a PackedScene variable like any other to link to another scene. So I immediately thought of this:

export(PackedScene) var new_scene = null 

This looks much cleaner – especially the ability to initialize it to null, as well as having access to methods like can_instance() to catch any accidental false inputs int the editor… however, this looks like there is one important link of the chain I mentioned at the start missing. In the end, I’m still selecting the PackedScene as a path on disk, so when does the load() happen?

Is this a valid and correct use of the export keyword, or could this come back to haunt me later if I overuse it?