Mapping elements

要素を対応させる

Mapping is defined in math as a rule that assigns each element from one set to an element in another set. It can be discrete, like assigning a character to another character ("A" → "α") or linking a Social Security number to a person. Or it can be a function like $y = ax + b$ that continuously transforms one value into another.

数学で写像(マッピング)とは、ある集合の各要素を別の集合の要素に対応させるルールとして定義されます。文字を別の文字に対応させる(「A」→「α」)、マイナンバーを個人に紐付けるといった離散的なものや、 ****$y = ax + b$といった関数のように、値を連続的に変換するものもあります。

mapping.jpg

<aside> 💡

数学の本では写像と呼ぶのが一般的ですが、プログラミングなどコンピュータに関する場面では「マッピング」「マップする」という表現の方が多く使われます。写像とマップは同じ概念を指していますが、この関連性に気づかないまま使われることも少なくありません。このページでは、文脈に応じて写像とマッピングの両方を使いますが、同じ概念を指しています。

</aside>

A literal example of discrete mapping is a substitution cipher. The idea is to replace characters with another set of characters or symbols so that only someone who knows the combination can read it. You might have played around with this in childhood, or read a Sherlock Holmes story, The Adventure of the Dancing Men.

離散的な写像の具体的な例として代換式暗号があります。これは、文字を別の文字や記号に置き換えることで、組み合わせを知っている人だけが読めるようにする方法です。子供の頃にこれで遊んだことや、シャーロック・ホームズの「踊る人形」を読んだことがある方もいるでしょう。

The demo below generates a mapping from the 26 alphabet letters to another randomized set. You can click on the canvas to shuffle the cipher.

下のデモでは、26個のアルファベットを別のランダムな文字に対応させる写像を生成します。キャンバスをクリックすると暗号がシャッフルされます。

https://codepen.io/kynd/pen/ZYzdzVL

Set of all possible input values is called domain, and the set of all possible output values is called range. In this example, the domain and range are both the set of 26 alphabets.

可能な入力値のすべての集合を定義域、可能な出力値すべての集合を値域と呼びます。この例では、定義域と値域はどちらも26個のアルファベットの集合です。