Minimising an Integrated Relative Entropy Functional

Suppose I am given

  • A probability distribution on $ \mathbf R^d$ , with density $ \pi (x)$ .
  • A family of transition kernels $ \{ q^0 (x \to \cdot) \}_{x \in \mathbf R^d}$ on $ \mathbf R^d$ , with densities $ q^0 (x \to y)$ .

I now want to find a new family of transition kernels $ \{ q^1 (x \to \cdot) \}_{x \in \mathbf R^d}$ such that

  • $ q^1$ is in detailed balance with respect to $ \pi$ , i.e.

\begin{align} \pi (x) q^1 ( x \to y ) = \pi (y) q^1 ( y \to x) \end{align}

  • $ q^1$ are as close as possible to $ q^0$ in KL divergence, averaged across $ x \sim \pi$ .

To this end, I introduce the following functional

\begin{align} \mathbb{F} [ q^1 ] &= \int_{x \in \mathbf R^d} \pi (x) \cdot KL \left( q^1 (x \to \cdot ) || q^0 (x \to \cdot ) \right) dx\ &= \int_{x \in \mathbf R^d} \int_{y \in \mathbf R^d} \pi (x) \cdot q^1 (x \to y) \log \frac{ q^1 (x \to y) }{ q^0 (x \to y) } \, dx dy \ &= \int_{x \in \mathbf R^d} \int_{y \in \mathbf R^d} \pi (x) \cdot \left\{ q^1 (x \to y) \log \frac{ q^1 (x \to y) }{ q^0 (x \to y) } – q^1 (x \to y) + q^0 (x \to y) \right \} \, dx dy. \end{align}

I thus wish to minimise $ \mathbb{F}$ over all transition kernels $ \{ q^1 (x \to \cdot) \}_{x \in \mathbf R^d}$ satisfying the desired detailed balance condition. Implicitly, there are also the constraints that the $ q^1$ are nonnegative and normalised.

I would like to solve this minimisation problem, or at least derive e.g. an Euler-Lagrange equation for it.

Currently, I can show that the first variation of $ \mathbb{F}$ is given by

\begin{align} \left( \frac{d}{dt} \vert_{t = 0} \right) \mathbb{F} [q^1 + t h] = \int_{x \in \mathbf R^d} \int_{y \in \mathbf R^d} \pi (x) \cdot \log \frac{ q^1 (x \to y) }{ q^0 (x \to y) } \cdot h (x, y) \, dx dy. \end{align}

Moreover, my constraints stipulate that any admissible variation $ h$ must satisfy the following two conditions:

  1. $ \forall x, y, \quad \pi (x) h (x, y) = \pi (y) h (y, x)$
  2. $ \forall x, \quad \int_{y \in \mathbf R^d} h (x, y) dy = 0$

I have not been able to translate these conditions into an Euler-Lagrange equation. I acknowledge that since the functional involves no derivatives of $ q^1$ , the calculus of variations approach may be ill-suited. If readers are able to recommend alternative approaches, this would also be appreciated. Anything which would allow for a more concrete characterisation of the optimal $ q^1$ would be ideal.

Domain Functional Level Still At Pre-Upgrade Level

I upgraded out Domain Controllers and Servers from Windows Server 2008 R2 to Windows Server 2016 via Windows Server 2012. Before the process of each jump:

From Windows Server 2008 R2 to Windows Server 2012 R2 From Windows Server 2012 R2 to Windows Server 2016

I successfully ran /forestprep & /domainprep without an issue on both Domain Controllers.

After the upgrades I went over to my Active Directory to check the functional level and it still says Windows Server 2008 R2.

Why would this be? I am upgrading all my Windows 7 machines to Windows 10. I have a few machines still running Windows 7 Embedded but I don’t think that would effect the level. I am a little confused. Do I need to now upgrade the Domain Funcational level once more now that the upgrade is complete?

Extension of a “statistical limit functional”

$ c=$ The set of all real convergent sequences

$ l_\infty=$ The set of all real bounded sequences

Clearly $ c\subset l_\infty$

$ f:c\to \mathbb R$ is called limit functional defined by $ f(x)=\lim\limits_{n\to\infty} x_n$

There exist infinitely many extensions of $ f$ to $ l_\infty$ . From here main concept of Banach Limit functional comes.

With the help of this Banach limits the notion of almost convergence is defined.

My Question : What happens if we take extensions of the statistical limit functional $ g$ ?

(where $ g:st\to \mathbb R$ is defined by $ g(x)=stat\lim\limits_{n\to\infty} x_n$ )

Here, $ st=$ The set of all bounded statistically convergent sequences.

May we define a new kind of convergence in this approach? Is it not available in literature?

Using functional interface arguments in methods of services injected via Spring

Here is the working code for my Spring service:

@Service public class UploadService {      @Inject     @Qualifier("session")     Session session;      @Inject     AsyncImageConvertService asyncImageConvertService;      @Value("$  {aws.bucket-name}")     String awsBucketName;      @Inject     AmazonS3 amazonS3;      @Inject     ImageMapper imageMapper;      @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED)     public void uploadImage(Image image, String url, Runnable fnSaveObject) {         File file = new File(System.getProperty("java.io.tmpdir"), image.getUrl());          image.setUrl(url);         image.setCreator(session.getUser());         PutObjectRequest request = new PutObjectRequest(awsBucketName, image.getUrl(), file);         request.setCannedAcl(CannedAccessControlList.PublicRead);         amazonS3.putObject(request);          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {             public void afterCommit() {                 asyncImageConvertService.processImage(image.getId(), file);             }         });          imageMapper.insert(image);         fnSaveObject.run();     } } 

It is called from the following code:

uploadService.uploadImage(                 profileImage,                 "/user/" + user.getId() + "/" + profileImage.getUrl(),                 () -> userMapper.insertImage(user, profileImage) ); 

The Runnable functional interface will run in transaction and invoke async service method after transaction committed.

*Mapper is injected instance also, via spring-mybatis.

This code looks like it’s working well, but I’m afraid it’s not safe.

Is it safe to use functional interface arguments in methods of services injected via Spring?

Windows Security App on Windows 10 not fully functional by default

I am trying to address the warning within Windows Security in Windows 10 that reads:

Virus & Threat Protection: Actions recommended

However, when I click on Open Windows Security I get the following pop-up message:

enter image description here

and selecting

Look for App in Microsoft Store

does not yield any results.

What am I missing? Is my PC compromised, or is there an App that I have to purchase or install?

How is functional property guaranteed in type theory when function type is defined?

I understand that functions are not defined in type theory the same way they are defined in set theory, hence functional property is not directly defined when defining function type in type theory. But I want to know which part of function type definition in type theory guarantees functional property even if it is done so indirectly and implicitly?

Functional Programming Hangman Practice

Recently, I have been trying to improve my functional programming skills and understanding. While at work today, my coworkers and I were playing Hangman in a group chat. I thought of a program that would guess the likeliest letter in the word to guess. So I implemented it when I got home. Here is the repository if you would like any more information (such as the word text file that is required for this script).

I would definitely appreciate comments on the readability of my code, as well as the uses of functional programming. Also, I was thinking that I may have been over commenting in my code. Is that the case?

import re   def get_words(word_len):     # Open the file with all the words in the English language.     with open("words.txt") as word_file:         # Get all the words without any newlines.         words_temp = map(lambda s: s.strip(), word_file.readlines())         # filter the words so that they have the same number of characters as the word in play.         words = [word.lower() for word in words_temp if len(word) is word_len]         # Get rid of any possible duplicates in the file.         words = list(set(words))     return words   def get_possible_words(guesses, current_word):     # The total number of characters in the word.     num_of_characters = len(current_word)      # Load the words in from the words.txt file.     words = get_words(num_of_characters)      # Get all words with just letters.     words = list(filter(lambda w: w.isalpha(), words))      # Regex will give us an error if we have     # no wrong guesses, so if we don't need to exclude     # anything, include everything!     if len(guesses) is 0:         substitute = '.'     else:         # exclude all of the wrong guesses         substitute = f"[^{guesses}]"      # Make the current_word a regex phrase.     current_word_regex = current_word.replace('_', substitute)      # Get the regex object for the current word     regex_obj = re.compile(current_word_regex)      # Get all possible matches to the word.     possible_matches = list(map(lambda word: regex_obj.match(word), words))      # Get all the words from those matches (filter None matches)     possible_words = [match.string for match in possible_matches if match is not None]      # Print the list of possible words.     return possible_words   def get_statistics(possible_words):     # Join all of the words in the list into a giant string.     words_as_str = ''.join(possible_words)     # sort the characters in each word.     words_as_str = ''.join(sorted(words_as_str))      # get all of the characters in the words.     characters_in_words = ''.join(set(words_as_str))      # Get the frequencies of each letter in the words.     frequencies = {c: words_as_str.count(c) for c in characters_in_words}      return frequencies   def get_likeliest_letter(stats):     # Get the most likely letter to guess.     likeliest_letter = max(stats, key=stats.get)      # Get the likelihood of the letter as a percent.     likelihood = stats[likeliest_letter] / sum(stats.values()) * 100.0      return likeliest_letter, likelihood   def play_hangman():     is_playing = True     # All of the characters that the computer guessed wrong.     guesses = ""      # the number of guesses the computer has made.     num_of_guesses = 0      current_word = ""      was_correct = True      while is_playing:         # Get input from the user if the current word on the board         # changed or is new.         if was_correct:             print("What is currently on the board?")             current_word = input("(Input unknown characters with _) ").lower()          # if we found the word, we can stop playing.         if current_word.count('_') is 0:             break          # Get all of the possible words that can be guessed         possible_words = get_possible_words(guesses, current_word)          print(f"There are {len(possible_words)} possible words.")          # Print all of the possible words if there's not too many of them.         if len(possible_words) <= 10:             [print(word) for word in possible_words]          # Early exit if it we only have one guess.         if len(possible_words) is 1:             print(f"It's obviously {possible_words[0]}.")             break          # Get the frequencies of each character in the possible words.         stats = get_statistics(possible_words)          # Remove characters we've already guessed from the statistics.         [stats.pop(guessed_letter, None) for guessed_letter in guesses]          print("Your most likely letter is...")          likeliest_letter, likelihood = get_likeliest_letter(stats)          print(f"{likeliest_letter} with a likelihood of {likelihood:.2f}%")          was_correct = input("Was I correct? (y/n) ").lower() == 'y'          # add our guess to the total listing of guesses.         num_of_guesses += 1         guesses += likeliest_letter          # Print a new line to break each round up.         print("")      print(f"It took me {num_of_guesses} guesses to get it.")   if __name__ == '__main__':     play_hangman() 

Using Geocoder in a Functional Test

I am writing my first test in Drupal 8’s API and for some reason, I am unable to geocode.

When I run my code in a controller, it works fine, but when using a test, $ addressCollection evaluates to false and I get the message ‘The geocder returned FALSE’.

namespace Drupal\Tests\custom_tests\Functional;  use Drupal\Tests\BrowserTestBase;  /**  * Test that Geocoder works  * Source: https://deninet.com/node/1631  *   * Note: need to have Gecoder: Google Maps configured properly before testing.  *   * @group custom_tests  */ class GeocoderModuleTest extends BrowserTestBase {    /**    * The modules to load to run the test.    *    * @var array    */   public static $  modules = [     'geocoder',   ];    /**    * {@inheritdoc}    */   protected function setUp() {     parent::setUp();      // $  this->geocoder = \Drupal::service('geocoder');     $  this->geocoder = $  this->container->get('geocoder');      /* Values tested for */     $  this->staticAddress = 'St Patrick\'s Close, Wood Quay, Dublin 8, Ireland';     $  this->staticCordinates = [       'longitude' => 53.339529,       'latitude' => -6.271501,     ];   }    /**    * Tests the setting form.    */   public function testForm() {      $  plugins = array('googlemaps');     $  address = '1 Centennial Square, Victoria, BC V8W 1P6'; // Victoria City Hall      // $  this->geocoder = \Drupal::service('geocoder');     $  addressCollection = $  this->geocoder->geocode($  address, $  plugins);      if ($  addressCollection) {       $  this->assertTrue(TRUE);       // $  coordinates = $  addressCollection->first()->getCoordinates();        // /* Check the longitudes */       // $  this->assertEquals(       //   $  staticCordinates['longitude'],        //   $  coordinates->getLongitude(),        //   'The latitudes didn\'t match',       //   0.001);        // /* Check the latitudes */       // $  this->assertEquals(       //   $  staticCordinates['latitude'],       //   $  coordinates->getLatitude(),       //   'The longitudes didn\'t match',        //   0.001);     } else {       $  this->assertFalse(TRUE, 'The geocder returned FALSE');     }   } } 

Should opportunistic refactoring happen in a different branch to functional changes

I’m not talking about the usual refactoring of new code you do as part of a development. This is more Boy Scout Principle type changes.

While I understand why they’re all made in the same branch, it seems there is some mileage in keeping them separate:

  • The intention of the functional change is clearer in the maintenance phase
  • Code review for the functional change is shorter
  • It makes it easier to grok a module in a branch as there are fewer changes
  • The functional change can be submitted faster while the opportunistic refactoring can take place at a more suitable time

Any thoughts?

Connection between Schur multipliers in representation theory and functional analysis?

I was wondering if there is any connection between two things called Schur multipliers or is it just a coincidence? Namely, in representation/group theory the Schur multiplier of a group $ G$ is its second homology group $ H_2(G, \mathbb{Z})$ . In functional analysis a function $ \varphi \colon \mathbb{N} \times \mathbb{N} \to \mathbb{C}$ is a Schur multiplier if for any bounded linear operator $ A: l^2 \to l^2$ with matrix $ (a_{i,j})_{i,j \in \mathbb{N}}$ (with respect to the standard orthonormal basis of $ l^2$ ) the matrix $ (\varphi(i,j)a_{i,j})_{i,j \in \mathbb{N}}$ defines a bounded linear operator.