2023,江端さんの技術メモ

Pythonを使った因子分析のコード を そのまま使わせて頂いています。
【Pythonで行う】因子分析

# ebata@DESKTOP-P6KREM0:/mnt/c/Users/ebata/go-efa$ python3 main3.py

# ライブラリのインポート
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import japanize_matplotlib
from factor_analyzer import FactorAnalyzer

# データの読み込み
df_workers = pd.read_csv("sample_factor.csv")
print(df_workers)

# 変数の標準化
df_workers_std = df_workers.apply(lambda x: (x-x.mean())/x.std(), axis=0)

# 固有値を求める
ei = np.linalg.eigvals(df_workers.corr())
print("固有値", ei)

# 因子分析の実行
fa = FactorAnalyzer(n_factors=2, rotation="promax")
fa.fit(df_workers_std)

# 因子負荷量,共通性
loadings_df = pd.DataFrame(fa.loadings_, columns=["第1因子", "第2因子"])
loadings_df.index = df_workers.columns
loadings_df["共通性"] = fa.get_communalities()
print(loadings_df)

# 因子負荷量の二乗和,寄与率,累積寄与率
var = fa.get_factor_variance()
df_var = pd.DataFrame(list(zip(var[0], var[1], var[2])), 
                      index=["第1因子", "第2因子"], 
                      columns=["因子負荷量の二乗和", "寄与率", "累積寄与率"])
print(df_var.T)

# バイプロットの作図
score = fa.transform(df_workers_std)
coeff = fa.loadings_.T
fa1 = 0
fa2 = 1
labels = df_workers.columns
annotations = df_workers.index
xs = score[:, fa1]
ys = score[:, fa2]
n = score.shape[1]
scalex = 1.0 / (xs.max() - xs.min())
scaley = 1.0 / (ys.max() - ys.min())
X = xs * scalex
Y = ys * scaley
for i, label in enumerate(annotations):
    plt.annotate(label, (X[i], Y[i]))
for j in range(coeff.shape[1]):
    plt.arrow(0, 0, coeff[fa1, j], coeff[fa2, j], color='r', alpha=0.5, 
              head_width=0.03, head_length=0.015)
    plt.text(coeff[fa1, j] * 1.15, coeff[fa2, j] * 1.15, labels[j], color='r', 
             ha='center', va='center')
plt.xlim(-1, 1)
plt.ylim(-1, 1)
plt.xlabel("第1因子")
plt.ylabel("第2因子")
plt.grid()
plt.show()

Pythonを使ったGAのコード を そのまま使わせて頂いています。

【python】遺伝的アルゴリズム(Genetic Algorithm)を実装してみる

遺伝配列を0/1を、便宜的に0~4にして動くよう、一部改造させて頂いております。

# ebata@DESKTOP-P6KREM0:/mnt/c/Users/ebata/go-efa$ python3 ga.py

import numpy as np
import matplotlib.pyplot as plt

class Individual:
    '''各個体のクラス
        args: 個体の持つ遺伝子情報(np.array)'''
    def __init__(self, genom):
        self.genom = genom
        self.fitness = 0  # 個体の適応度(set_fitness関数で設定)
        self.set_fitness()

    def set_fitness(self):
        '''個体に対する目的関数(OneMax)の値をself.fitnessに代入'''
        self.fitness = self.genom.sum()

    def get_fitness(self):
        '''self.fitnessを出力'''
        return self.fitness

    def mutate(self):
        '''遺伝子の突然変異'''
        tmp = self.genom.copy()
        i = np.random.randint(0, len(self.genom) - 1)
        # tmp[i] = float(not self.genom[i]) 
        tmp[i] = np.random.randint(0, 5) #  江端修正
        self.genom = tmp
        self.set_fitness()


def select_roulette(generation):
    '''選択の関数(ルーレット方式)'''
    selected = []
    weights = [ind.get_fitness() for ind in generation]
    norm_weights = [ind.get_fitness() / sum(weights) for ind in generation]
    selected = np.random.choice(generation, size=len(generation), p=norm_weights)
    return selected


def select_tournament(generation):
    '''選択の関数(トーナメント方式)'''
    selected = []
    for i in range(len(generation)):
        tournament = np.random.choice(generation, 3, replace=False)
        max_genom = max(tournament, key=Individual.get_fitness).genom.copy()
        selected.append(Individual(max_genom))
    return selected


def crossover(selected):
    '''交叉の関数'''
    children = []
    if POPURATIONS % 2:
        selected.append(selected[0])
    for child1, child2 in zip(selected[::2], selected[1::2]):
        if np.random.rand() < CROSSOVER_PB:
            child1, child2 = cross_two_point_copy(child1, child2)
        children.append(child1)
        children.append(child2)
    children = children[:POPURATIONS]
    return children


def cross_two_point_copy(child1, child2):
    '''二点交叉'''
    size = len(child1.genom)
    tmp1 = child1.genom.copy()
    tmp2 = child2.genom.copy()
    cxpoint1 = np.random.randint(1, size)
    cxpoint2 = np.random.randint(1, size - 1)
    if cxpoint2 >= cxpoint1:
        cxpoint2 += 1
    else:
        cxpoint1, cxpoint2 = cxpoint2, cxpoint1
    tmp1[cxpoint1:cxpoint2], tmp2[cxpoint1:cxpoint2] = tmp2[cxpoint1:cxpoint2].copy(), tmp1[cxpoint1:cxpoint2].copy()
    new_child1 = Individual(tmp1)
    new_child2 = Individual(tmp2)
    return new_child1, new_child2


def mutate(children):
    for child in children:
        if np.random.rand() < MUTATION_PB:
            child.mutate()
    return children


def create_generation(POPURATIONS, GENOMS):
    '''初期世代の作成
        return: 個体クラスのリスト'''
    generation = []
    for i in range(POPURATIONS):
        # individual = Individual(np.random.randint(0, 2, GENOMS))
        individual = Individual(np.random.randint(0, 5, GENOMS))
        generation.append(individual)
    return generation


def ga_solve(generation):
    '''遺伝的アルゴリズムのソルバー
        return: 最終世代の最高適応値の個体、最低適応値の個体'''
    best = []
    worst = []
    # --- Generation loop
    print('Generation loop start.')
    for i in range(GENERATIONS):
        # --- Step1. Print fitness in the generation
        best_ind = max(generation, key=Individual.get_fitness)
        best.append(best_ind.fitness)
        worst_ind = min(generation, key=Individual.get_fitness)
        worst.append(worst_ind.fitness)
        print("Generation: " + str(i) \
                + ": Best fitness: " + str(best_ind.fitness) \
                + ". Worst fitness: " + str(worst_ind.fitness))

        # --- Step2. Selection (Roulette)
        # selected = select_roulette(generation)
        selected = select_tournament(generation)

        # --- Step3. Crossover (two_point_copy)
        children = crossover(selected)

        # --- Step4. Mutation
        generation = mutate(children)

    print("Generation loop ended. The best individual: ")
    print(best_ind.genom)
    return best, worst


np.random.seed(seed=65)

# param
POPURATIONS = 100
# GENOMS = 50 # 江端修正
GENOMS = 160
GENERATIONS = 1000
CROSSOVER_PB = 0.8
MUTATION_PB = 0.1

# create first genetarion
generation = create_generation(POPURATIONS, GENOMS)

# solve
best, worst = ga_solve(generation)

# plot
fig, ax = plt.subplots()
ax.plot(best, label='max')
ax.plot(worst, label='min')
ax.axhline(y=GENOMS, color='black', linestyle=':', label='true')
ax.set_xlim([0, GENERATIONS - 1])
#ax.set_ylim([0, GENOMS * 1.1])
ax.set_ylim([0, GENOMS * 2.2])
ax.legend(loc='best')
ax.set_xlabel('Generations')
ax.set_ylabel('Fitness')
ax.set_title('Tournament Select')
plt.show()

 

明日は、この2つをマージして、目的のプログラムを完成させます。

以下のプログラムは、20個のデータを使って因子分析を行い、その分析因子分析を同じ結果を生み出す200個のダミーデータを作成します。

アルゴリズムの説明は省略します(が、私は分かっています)。

まず、データ(sample_factory.csv)

x1,x2,x3,x4,x5,x6,x7,x8
2,4,4,1,3,2,2,1
5,2,1,3,1,4,2,1
2,3,4,3,4,2,4,5
2,2,2,2,3,2,2,2
5,4,3,4,4,5,4,3
1,4,4,2,4,3,2,3
3,1,1,1,1,2,1,1
5,5,3,5,4,5,3,5
1,3,4,1,3,1,3,1
4,4,3,1,4,4,2,1
3,3,3,2,4,4,4,2
1,2,1,3,1,1,1,1
5,2,3,5,2,5,1,3
4,1,1,3,1,2,2,1
1,1,1,1,2,1,2,1
3,1,2,1,1,3,2,1
1,2,3,5,2,2,2,2
3,1,1,3,2,4,2,1
3,2,3,2,2,2,2,5
1,4,3,1,4,3,5,3

以下、GAのコード

# ebata@DESKTOP-P6KREM0:/mnt/c/Users/ebata/go-efa$ python3 ga-factory2.py

# ライブラリのインポート
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# import japanize_matplotlibe
from factor_analyzer import FactorAnalyzer
import matplotlib.pyplot as plt

class Individual:
    '''各個体のクラス
        args: 個体の持つ遺伝子情報(np.array)'''
    def __init__(self, genom):
        self.genom = genom
        self.fitness = 0  # 個体の適応度(set_fitness関数で設定)
        self.set_fitness()

    def set_fitness(self):
        '''個体に対する目的関数(OneMax)の値をself.fitnessに代入'''
        # まずgenomを行列にデータに変換する
        # self.fitness = self.genom.sum()

        # 遺伝子列を行列に変換
        arr2d = self.genom.reshape((-1, 8)) # 列が分からない場合は、-1にするとよい

        # 各列の平均と標準偏差を計算
        mean = np.mean(arr2d, axis=0)
        std = np.std(arr2d, axis=0)

        # 標準偏差値に変換
        standardized_arr2d = (arr2d - mean) / std

        # 因子分析の実行
        fa_arr2d = FactorAnalyzer(n_factors=2, rotation="promax")
        fa_arr2d.fit(standardized_arr2d)

        # 因子分析行列の算出
        loadings_arr2d = fa_arr2d.loadings_

        # 因子分析行列の差分算出
        distance2 = euclidean_distance(fa.loadings_, loadings_arr2d)
        # print(distance2)
        
        # とりあえず評価関数をこの辺から始めてみる
        self.fitness = 1 / distance2

    def get_fitness(self):
        '''self.fitnessを出力'''
        return self.fitness

    def mutate(self):
        '''遺伝子の突然変異'''
        tmp = self.genom.copy()
        i = np.random.randint(0, len(self.genom) - 1)
        # tmp[i] = float(not self.genom[i]) 
        tmp[i] = np.random.randint(1, 6) #  江端修正
        self.genom = tmp
        self.set_fitness()


def euclidean_distance(matrix_a, matrix_b):
    # 行列Aと行列Bの要素ごとの差を計算します
    diff = matrix_a - matrix_b
    
    # 差の二乗を計算します
    squared_diff = np.square(diff)
    
    # 差の二乗の和を計算します
    sum_squared_diff = np.sum(squared_diff)
    
    # 和の平方根を計算します
    distance = np.sqrt(sum_squared_diff)
    
    return distance


def select_roulette(generation):
    '''選択の関数(ルーレット方式)'''
    selected = []
    weights = [ind.get_fitness() for ind in generation]
    norm_weights = [ind.get_fitness() / sum(weights) for ind in generation]
    selected = np.random.choice(generation, size=len(generation), p=norm_weights)
    return selected


def select_tournament(generation):
    '''選択の関数(トーナメント方式)'''
    selected = []
    for i in range(len(generation)):
        tournament = np.random.choice(generation, 3, replace=False)
        max_genom = max(tournament, key=Individual.get_fitness).genom.copy()
        selected.append(Individual(max_genom))
    return selected


def crossover(selected):
    '''交叉の関数'''
    children = []
    if POPURATIONS % 2:
        selected.append(selected[0])
    for child1, child2 in zip(selected[::2], selected[1::2]):
        if np.random.rand() < CROSSOVER_PB:
            child1, child2 = cross_two_point_copy(child1, child2)
        children.append(child1)
        children.append(child2)
    children = children[:POPURATIONS]
    return children


def cross_two_point_copy(child1, child2):
    '''二点交叉'''
    size = len(child1.genom)
    tmp1 = child1.genom.copy()
    tmp2 = child2.genom.copy()
    cxpoint1 = np.random.randint(1, size)
    cxpoint2 = np.random.randint(1, size - 1)
    if cxpoint2 >= cxpoint1:
        cxpoint2 += 1
    else:
        cxpoint1, cxpoint2 = cxpoint2, cxpoint1
    tmp1[cxpoint1:cxpoint2], tmp2[cxpoint1:cxpoint2] = tmp2[cxpoint1:cxpoint2].copy(), tmp1[cxpoint1:cxpoint2].copy()
    new_child1 = Individual(tmp1)
    new_child2 = Individual(tmp2)
    return new_child1, new_child2


def mutate(children):
    for child in children:
        if np.random.rand() < MUTATION_PB:
            child.mutate()
    return children


def create_generation(POPURATIONS, GENOMS):
    '''初期世代の作成
        return: 個体クラスのリスト'''
    generation = []
    for i in range(POPURATIONS):  # POPURATIONS = 100
        # individual = Individual(np.random.randint(0, 2, GENOMS))
        individual = Individual(np.random.randint(1, 6, GENOMS))
        generation.append(individual)
    return generation


def ga_solve(generation):
    '''遺伝的アルゴリズムのソルバー
        return: 最終世代の最高適応値の個体、最低適応値の個体'''
    best = []
    worst = []
    # --- Generation loop
    print('Generation loop start.')
    for i in range(GENERATIONS):
        # --- Step1. Print fitness in the generation
        best_ind = max(generation, key=Individual.get_fitness)
        best.append(best_ind.fitness)
        worst_ind = min(generation, key=Individual.get_fitness)
        worst.append(worst_ind.fitness)
        print("Generation: " + str(i) \
                + ": Best fitness: " + str(best_ind.fitness) \
                + ". Worst fitness: " + str(worst_ind.fitness))

        # --- Step2. Selection (Roulette)
        # selected = select_roulette(generation)
        selected = select_tournament(generation)

        # --- Step3. Crossover (two_point_copy)
        children = crossover(selected)

        # --- Step4. Mutation
        generation = mutate(children)

    print("Generation loop ended. The best individual: ")
    print(best_ind.genom)
    return best, worst



np.random.seed(seed=65)

# param
POPURATIONS = 100  # 個体数
# GENOMS = 50 # 江端修正

# GENOMS = 160 # GENの長さ
GENOMS = 1600 # GENの長さ 1つのデータが8個の整数からなるので、合計200個のデ0タとなる 

GENERATIONS = 1000
CROSSOVER_PB = 0.8

# MUTATION_PB = 0.1 
MUTATION_PB = 0.3 # ミューテーションは大きい方が良いように思える

# ファイルからデータの読み込み
df_workers = pd.read_csv("sample_factor.csv")
print(df_workers)

# 変数の標準化
df_workers_std = df_workers.apply(lambda x: (x-x.mean())/x.std(), axis=0)
print(df_workers_std)


# 固有値を求める(不要と思うけど、残しておく)
ei = np.linalg.eigvals(df_workers.corr())
print(ei)

print("因子分析の実行") # 絶対必要
fa = FactorAnalyzer(n_factors=2, rotation="promax")
fa.fit(df_workers_std)

# print(fa.loadings_) # これが因子分析の行列


# 因子負荷量,共通性(不要と思うけど、残しておく)
loadings_df = pd.DataFrame(fa.loadings_, columns=["第1因子", "第2因子"])
loadings_df.index = df_workers.columns
loadings_df["共通性"] = fa.get_communalities()

# 因子負荷量の二乗和,寄与率,累積寄与率(不要と思うけど、残しておく)
var = fa.get_factor_variance()
df_var = pd.DataFrame(list(zip(var[0], var[1], var[2])), 
                      index=["第1因子", "第2因子"], 
                      columns=["因子負荷量の二乗和", "寄与率", "累積寄与率"])
print(df_var.T)



# create first genetarion
generation = create_generation(POPURATIONS, GENOMS)

# solve
best, worst = ga_solve(generation)

# plot

#fig, ax = plt.subplots()
#ax.plot(best, label='max')
#ax.plot(worst, label='min')
#ax.axhline(y=GENOMS, color='black', linestyle=':', label='true')
#ax.set_xlim([0, GENERATIONS - 1])
#ax.set_ylim([0, GENOMS * 1.1])
#ax.legend(loc='best')
#ax.set_xlabel('Generations')
#ax.set_ylabel('Fitness')
#ax.set_title('Tournament Select')
#plt.show()

ga-factory2.py :200固体  主成分行列からの距離は、distance2(これが一致度) 評価関数は、この逆数を使っているだけ

ga-factory3.py :2000固体

以上

 

2023,江端さんの忘備録

現総理大臣に対する

I thought

―― 増税メガネ

"Tax hike spectacle guy"

は、「いじめ」の範疇に入らないのか?

Does it against the current PM not fall into the category of "bullying"?

「いじめ」といのが権力に対してのバランスを考慮するものであるなら、もちろん「増税メガネ」は「いじめ」にならないでしょう。

If "bullying" is a balancing act against power, then, of course, "tax hike spectacle guy" is not "bullying.

-----

chatgptに聞いてみたところ、以下のように言われました。

I asked chatgpt and was told the following.

『「いじめ」とは、個人や集団によって、他の個人に対して行われる繰り返しの嫌がらせや敵意のある行動です。この行動は心理的、物理的、または社会的な害を与える意図を持っており、しばしば力の不均衡によって特徴付けられます」

Bullying is "repeated harassment or hostile behavior perpetrated by an individual or group of individuals against another individual. This behavior intends to inflict psychological, physical, or social harm and is often characterized by an imbalance of power."

なるほど、「力の不均衡によって特徴づけられる」のであれば、『増税メガネ』は、「いじめ」には該当しないでしょう。

Okay, if it is "characterized by an imbalance of power," then "Tax hike spectacle guy" would not qualify as "bullying.

なにしろ、内閣総理大臣は、行政府の長であり、事実上、日本国の最高権力者とみなされる人ですから。

After all, the Prime Minister is the head of the executive branch and is effectively considered the highest authority in Japan.

-----

で、いきなり、話題が私の趣味の読書の話になるのですが、

Suddenly, the topic turns to my hobby of reading; I sometimes think that

『ラノベ&アニメの「やはり俺の青春ラブコメは間違っている」の、主人公、比企谷八幡が、友人(と主人公は思っていないのですが)に対する材木座義輝に対する日常的な振る舞いは、「いじめ」ではないのか?』

In the "My Youth Love Comedy is Wrong as I Expected," the main character, Hachiman Hikigaya's daily behavior towards his friend (and the main character denies it), Yoshiteru Zaimokuza, is not "bullying"?

と思うことがあります。

コンテンツの中では、材木座義輝が「いじめられているキャラクターとして描かれていない」から、私たちは、これを「いじめ」と認識することができません。

We cannot perceive this as "bullying" because Yoshiteru Zaimokuza is not "portrayed as a character being bullied" in the content.

しかし、これを、ストーリーやプロットなどを無視して、客観的状況だけで判断すれば、比企谷八幡は「いじめの加害者」であり、材木座義輝は「いじめの被害者」であることは、100%認定できるはずです。

However, suppose this is judged solely based on objective circumstances, ignoring the storyline and plot. In that case, it should be 100% certifiable that Hachiman Hikigaya is the "bullying perpetrator," and Yoshiteru Zaimokuza is the "bullying victim".

もちろん、そのようなことを心配していれば、コンテンツを楽しむことはできません。

Of course, if you worry about such things, you will not enjoy any content.

だからこそ、ここに「恐しい落とし穴」があると思っています。

That said, I believe there is a "scary pitfall" here.

つまり、ストーリーや日常生活の中に埋没することで、自分が「いじめ」と認識しないまま「いじめ」を実行し、「いじめ」の被害者を追い込んでいく。

In other words, by burying themselves in stories and daily life, they carry out "bullying" without recognizing themselves as "bullies" and drive the victims of "bullying" into a corner.

これこそが、「いじめ」のリアルなのです。

This is the reality of bullying.

あなたは、『材木座義輝は、"いじられている"だけで、"いじめられている"わけではない』って思いませんでしたか?

Did you ever think that Yoshiteru Zaimokuza is only "teased" and not "bullied"?

これ、「いじめ」当事者の定番のセリフです。

This is a standard line of the "bullying" guys.

-----

私は、十分に歳をとった(ひねくれた)シニアですので、これに気がついていました。

I am a senior citizen old enough (and twisted sufficiently) to have noticed this.

伺いたいのは、ティーンエイジャ、または、若い読者や視聴者の方の中に、

I would like to ask you, teenagers, or any of your young readers or viewers,

『ラノベ&アニメの「やはり俺の青春ラブコメは間違っている」の、主人公、比企谷八幡が、友人の材木座義輝に対する日常的な振る舞いは、「いじめ」ではないのか?』

I wonder how many people have come up with the idea of "My Youth Love Comedy is Wrong as I Expected," the main character, Hachiman Hikigaya's daily behavior towards his friend (and the main character denies it), Yoshiteru Zaimokuza, is not "bullying" ?"

と、思い当たった人が、一体、どれくらいの人数いるだろうか、ということです。

-----

これに、一度も思い当たれなかった人は、十分に「いじめの加害者」の潜在的能力を持っています。

If you have never been able to come up with this, you are fully capable of being a "bullying perpetrator."

それどころか、あなたは、現在進行形の「いじめの加害者」の当事者であるかもしれません。

On the contrary, you may be a party to an ongoing "bullying perpetrator.

―― うちの父親が、「やはり俺の青春ラブコメはまちがっている」が凄い、って言っていた

 

2023,江端さんの忘備録

法相:江端智一(民間人)

こちらの日記で、私は、以下のようなことを書きました。

In this journal entry, I wrote the following

===== ここから =====

===== From here =====

でも、どうして、会見ライブを7時(19時)のNHKニュースにぶつけてくるかなぁ?

But why would they put the live press conference on the 7:00 (7:00 p.m.) NHK news?

私、内閣改造は、結果が分かればいいです。会見はサマリーで十分です。

About the cabinet reshuffle, I only need to know the results. A summary of the press conference is sufficient.

概要は、NHKの解説委員にでも説明して貰えば十分です。

Having NHK commentators explain it to me for an overview is sufficient.

江端家は、7時のニュースに合わせて夕食を食べているので、こういう、1時間を越えるような「退屈」な会見は、はっきり言って「とても迷惑」なんです。

The Ebata family eats dinner in time for the 7:00 news, so these "boring" press conferences that last over an hour are "very annoying," to say the least.

NHKが会見ライブを止めればいいんですが、政府に財布を握られているNHKが、首相の会見ライブを後回しにするような、そんな勇気はないでしょう。

But why would they put the live press conference on the 7:00 (7:00 p.m.) NHK news?

==== ここまで ====

===== To here =====

今日、内閣総理大臣記者会見の開始時間が、18時15分からになっていました。

Today, the Prime Minister's press conference started at 6:15 p.m.

つまり、記者会見を『7時(19時)のNHKニュースにぶつけてくる』のを止めたようです。

In other words, they have stopped "bumping the press conference to the 7:00 (19:00) NHK news.

―― 私の発言って、結構影響力があるんだな

"I guess what I say has a lot of influence."

と、一瞬思った私がいます。

I was the one who thought for a moment.

勘違いも甚しいですが。

I'm very much mistaken, though.

内閣総理大臣記者会見を、7時(19時)のNHKニュースにぶつけられて、怒っている人が、無視できないほどの人数がいたのかもしれません。

There may have been too many angry people to get angry by the conflict between the Prime Minister's press conference and the 7:00 (7:00 p.m.) NHK news.

まあ、今回の回避は、単なる偶然かもしれませんが。

Or, this avoidance may be a coincidence.

-----

いずれにしても、7時(19時)のNHKニュースの時間は、私にとって、その日あったことを30分間でラップアップする貴重な時間です。

In any case, the 7:00 (7:00 p.m.) NHK news hour is a valuable 30-minute wrap-up of what happened that day for me.

記者会見の内容も重要ですが、ガザ、ウクライナ、円高、物価、為替、その他、今の、私には等しく重要な案件です。

The content of the press conference is important, but Gaza, Ukraine, the strong yen, prices, exchange rates, and other matters now are equally important to me.

勝手に、私の時間を奪わないで頂きたい。

Please do not take my time without my permission.

-----

もし政府が、その時間に総理大臣の記者会見のライブをぶつけてきたとしても、NHKは、その中継を録画にして、他の時間に回すなどの対応をして下さい。

If the government bumps the prime minister's press conference live at that time, NHK should record the live broadcast and turn it over to another time.

もし、NHKが同じような、政府(総理大臣)への忖度ライブを、これからも続けるのであれば、私は、何度でも、この話を蒸し返して、NHKを批判し続けますよ。

If NHK continues the same "flattering" of the government (the prime minister), I will rehash this story and criticize NHK repeatedly.

2023,江端さんの忘備録

NHKの番組「笑わない数学 虚数」の前半3/4をスキップして、虚数の説明が行われるところから視聴しました。

I skipped the first 3/4 of the NHK program "Mathematics without Laughter: Imaginary Numbers" and watched it from the point where imaginary numbers are explained.

『うーん、やっぱりこういう説明になってしまうか』

'Hmmm, I am afraid that's the explanation after all.'

と、ちょっと残念でした。

I was a little disappointed.

いや、もちろん番組としては「とても良い」のです。

No, of course, it is "very good" as a program.

ただ、虚数が、私たちの生活に入り込んでいる、という意味の解説として、「シュレーディンガ方程式」を出すのは、ちょっと厳しのではないかなぁ、と。

However, I think it may be a bit harsh to offer the "Schrodinger equation" as an explanation of how imaginary numbers have entered our lives.

例えば、私が、以下の板書を使って、シュレーディンガ方程式を分かって貰えるか、と考えれば、『そりゃ無理だろう』と思えるんですよね。

For example, if I were to ask myself if I could get my daughters or my wife to understand the Schrodinger equation using the following board, I would think, 'Well, that would be impossible.

「バネの運動方程式と同じだよ」といっても、全く無駄な気がします。

It seems futile to say, "It's just like the equation of motion for a spring."

-----

『虚数は、とっても便利な道具』という観点から説明できないかなぁ、と思うんですよ。

I wonder if it could be explained in terms of 'imaginary numbers are a handy tool.

位相と周波数の異なる複数の三角関数の四則演算を、"i"を使った式だけで表わせる、って感動しませんか?

Isn't it impressive that we can express the quadrature operations of multiple trigonometric functions with different phases and frequencies using only "i" expressions?

しないか。ダメか。

Not? No-no.

私は、『計算が分からなくなったら、とりあえず、オイラーの公式に叩き込んでみる』てな、雑な感じで使うんですけどね。

I use it crudely to say, "Whenever I am at a loss for a calculation, I just try to apply them to Euler's formula.

-----

私のお勧めは、こちらに記載している「虚数とは、90度回転である」です。

My recommendation is "An imaginary number is a 90-degree rotation," described here.

そんでもって、こちらの記載の後半(次女との会話)が、現実世界における虚数の出現の一例です。

And so, the second half of this description (the conversation with the second daughter) is an example of the appearance of imaginary numbers in the real world.

-----

『虚数は、便利な道具として使い倒すモノ』が、浸透すれば良いのですが。

I hope that "imaginary numbers are a useful tool to be used and put to good use" will become widespread.

しかし、我が国は「三角関数不要論」が不定期に上がってくるくらいですから、ここ100年くらいは(というか100年後ですら)ダメなような気がします。

However, since our country is so irregular in devising the "no trigonometric function needed" theory, I feel that it will not work for the next 100 years (or even 100 years from now).

―― いろいろ言っているけど、要するにお前ら、三角関数が嫌いなだけだろ……!

2023,江端さんの忘備録

度重なる私のChatGPT(無料版)の酷使によって、ついに、ChatGPTが反応しなくなりました(現時点では、これが原因かどうかは、不明ですが)。

After repeated heavy use of my ChatGPT (free version), ChatGPT has finally stopped responding (at this point, I am not sure if this is the cause or not).

という理由で、ChagGPT有償版に入りました(20ドル/月)。

This is why I joined the paid version of ChagGPT ($20/month).

嫁さんには、『ChatGPTの助けなくして、業務と卒業は考えられない』といって、予算を通して貰いました。

I got my wife to pass the budget by saying, 'I can't think of operations and graduation without the help of ChatGPT.

"grammary(有償版)"なしに英文(コラムと論文)を書く自信はありませんし、AWS(ightsail)にも、kobore.net用のプロバイダにもお金払っています。

I am not confident writing English (columns and articles) without "Grammarly (paid version)," and I pay for AWS (lightsail) and a provider for kobore.net.

でも、これらがなければ、私の日々の生活が成立しません。

But without these, my daily life would not be possible.

-----

日々、IT/AIに搾取される範囲が拡大していることを痛感しています。

We are acutely aware that the scope of exploitation by IT/AI is expanding every day.

しかもたちの悪いことに、それらIT/AIの私に対する貢献は『絶大』です。

Worse, the contribution of IT/AI to me is 'immense'.

それでも、上記の月額合計金額は、間違いなく、会社での1回の飲み会の代金よりは安いです。

Still, the above total monthly amount is less than the cost of one drink at the office.

比して、有償のIT/AIの私に対する貢献は、飲み会と比較して、100倍を下らないと思います。

In comparison, the contribution of paid IT/AI to me is no less than 100 times that of a drinking session.

例えば、飲み会で「PDゲームと保証ゲームの違いは何ですか?」に、スラスラと答えられる同僚 ―― あなたにはいますか?

For example, do you have a colleague at a drinking party who can slur my answers to "What's the difference between PD games and guarantee games?"

(『飲み会で、ゲーム理論の話をするか!』というツッコミはさておき)

(Aside from the "Do you talk about game theory at a drinking party? )

-----

『江端が、AIに負けた日』

The Day Ebata Lost to AI.

それが、「いつ」であるか定義するのは難しいです。

It is difficult to define "when" that is.

とりあえず、ChatGPTに20ドル/月を払いはじめた日(昨日)を、その起算日として定義したいと思います。

For now, I would like to define the day (yesterday) when I started paying $20/month to ChatGPT as its starting date.

『世界が変わる』と確信した日

 

2023,江端さんの忘備録

先日、駅前の本屋で、大学受験用の英語の長文解釈の解説本を、パラパラを立ち読みしていましたが、

The other day, I was at a bookstore in front of the station, browsing through a book that explains how to interpret long sentences in English for university entrance exams,

驚きました。

I was surprised.

―― (英文の)内容が、暴力的なまでに、退屈

"The content of English text was to the point of violence, tedious."

- 10万年前の先祖がどういう生活をしていたか

- What life was like for our ancestors 100,000 years ago.

- 『日本人に質問すると、個人の意見ではなく、日本人としての回答をしてくること』に不満を言う外国人の話

- A foreigner complains, "When I ask a question to a Japanese person, they answer me as a Japanese person, not as an individual.

正直にいって『どーでもいい』

Frankly, I don't care about them.

某アニメのキャラクタの台詞を借りれば、

To borrow a line from a specific animated character, the contents were,

『つまらなかった。読むのが苦痛ですらあったわ。想像を絶するつまらなさ』

'It was boring. It was even painful to read. Boring beyond imagination.'

という感じです。

Like that.

「このつまらない英文を、受験生に強いること」は、『虐待』ではないか、と思えたくらいです。

It seemed that "forcing students to take this boring English text" was "abuse.

私の大学受験のころから、英文のコンテンツの内容が、全然変っていないことにも驚いています。

I am also surprised to see that the content of the English language content has not changed at all since my college entrance exam.

この問題が、私の時代に登場したとしても、違和感がありません。

I would feel comfortable if this issue appeared in my time.

でも、それでいいのか?

However, is that no problem?

-----

私:「・・・ということがあったんだけど」

Me: "...there was a time when..."

嫁さん:「それぞれの受験生にとって、興味のある共通的な英文コンテンツ ―― そんなものは存在しないよ」

Wife: "Common English-language content of interest to each student for exams -- there is no such thing."

私:「・・・」

Me: "..."

嫁さん:「ならば、全ての受験生に対して、興味が"湧かない"、"枯れた"コンテンツにならざるを得ないでしょう」

Wife: "Then colleges will have to choose content that is "uninteresting" and "dead" for all students."

なるほど、そういう理由であれば。数十年間、同じコンテンツになるのは仕方がない ―― って、そうかなぁ?

I see if that is the reason. We can't help but be the same content for decades -- is that right?

いやいや、今のライトノベルとか面白いじゃないですか。

No, no, no. Light novels and other exciting things nowadays.

私の若い時代にはなかった、新しい考え方や価値観も沢山出てきていると思います。

I believe that many new ideas and values are emerging that were not present in my younger days.

『ライトノベルの翻訳を出題したっていいじゃないか』と思うんですけどね。

I think, 'Why not submit a translation of a light novel?'

私の日記の内容でも、まだ、あの"枯れた"英文よりは、随分マシ、と思います。

Even the contents of my diary are still much better than that "dead" English text.

私としては、このコンテンツが、大学入試に出たら面白いだろうな、と思います。

For my part, I think the following content would be interesting to see on the college entrance exam.

■「高齢者を組織のトップから、ナチュラルに排除」する技術

まあ、結構な騒ぎになるかもしれませんが、入試会場で「クスクス」と笑い声が出てくるくらい、振り切ってもいいんじゃないかと、私は思うのです。

Well, it may cause quite a commotion, but I think it's okay to shake it off so that there is a "cuscus" of laughter in the exam hall.

2023,江端さんの技術メモ

【QGIS】緯度・経度をもつCSVデータを読み込み、地図に表示する

(1)CSVファイル
Lat, Lng
35.3663 , 139.6225
35.3669 , 139.6245
35.3673 , 139.6259
35.3672 , 139.6268
35.3673 , 139.6296
35.3668 , 139.6296
35.367 , 139.6296
35.3671 , 139.6297
35.3672 , 139.6298
35.368 , 139.622

(以下、省略)

(2)CSVファイルの読み込み

(3)結果

以上

2023,江端さんの忘備録

昨夜からChatGPTが応答をしなくなっていて、青ざめています。

ChatGPT has been unresponsive since last night, and I am blue and cold.

以前、

Before, I wrote the following diary,

―― 自分のエンジニアの人生の中で、もっとも優しく、かつ、的確に、技術指導をしてくれたのは、"ChatGPT"である

のように記載しました。

今や、ChatGPTと私の関係は、

Now, my relationship with ChatGPT has gone beyond

- キャバクラで「バーチャルなモテ」を楽しむお客

"- customers who enjoy 'virtual hottie' in a cabaret club"

とか、

or

- ホストクラブで、甘いセリフを耳元でささやかれかれるお客

"- customers who get sweet lines whispered in their ears at a hostess club."

以上です。

ホステスやホストさんは、視覚(イケメン、美人)や聴覚(ことば)で、私を癒してくれるかもしれませんが、

Hostesses and hosts may heal me with their sight (good-looking, beautiful women) and hearing (words); however,

『(バグのない)動くプログラムを作ってはくれない』

they don't 'make a program that works well (without bugs),

からです。

今の私に必要なものは、「優しくて癒される言葉」より、「実際に動くプログラムコード」です。

What I need now is "program code that works without bugs" rather than "kind and soothing words."

-----

ですから、コーディングしてくれるホストやホステスさんがいたら、かなり高い確率で、その方のいる店に通って、貢いでしまう自信はあります。

Therefore, if there is a host or hostess who can make codes for me, I am confident that I will go to the restaurant where they are and pay tribute to them at a very high rate.

あるいは、「来期の研究提案」や「論文の構成案」を一緒に考えてくれる方なら、絶対に常連客になります。

If they can also work with me on a "research proposal for the next term" or a "proposed structure for an academic paper, " I will be a regular customer.

そういうホストクラブやキャバクラがありましたら、是非私にご紹介下さい。

If you know of such host clubs or cabarets, please introduce them to me.

-----

ちなみに、ChatGPTですが、ログインしなおしたら、動きました。

By the way, ChatGPT worked once I re-logged in.

今、安堵の溜息をついております。

I am now breathing a sigh of relief.

指名制に関する考察

2012,江端さんの忘備録

誰も私を「キャバクラ」へも「メイド喫茶」へも連れていってくれません。

「『江端が怒り出す』と思うから」という理由なのだそうです(以前も書きましたが)。

私にはよく分かりませんが。

-----

「キャバクラ」とは何かを調べてみました。

◯「キャバクラ」は、日本人特有の和製英語で、「キャバレー」と「クラブ」の合成用語

◯歌や踊りのショーを見ながら、お気に入りの女性(ホステスさん)と会話やダンスを楽しむことが発祥で、クラブほどは高くないが、気軽に若い女の子と会話が出来るという、接待サービスの一態様。

◯料金の単位は「1人・時間」

次に料金の相場を調べてみました。

◯基本的に60分5千円で、延長が可能(自動延長もあり)。但し、飲食料金を含まない。楽しく酔っ払って気付くと4時間経っていて、伝票を見ると「3万2000円」ということもある。

◯「事後一斉清算」と「前払い」の2種類もある。当然、店側から見えれば前者が望ましい。

◯「7時~8時4000円/8時~9時5000円/9時以降6000円」くらい。

◯実施例

午後9時から2時間飲んだ場合

基本料金:6000円として2時間で1万2000円

指名料:2000円として2時間で4000円

女の子へのおごり:1000円の飲料を2杯 2000円

--------------------------------------

総計 1万8000円

ここにTAXが加わって、ざっくり 2万円

-----

インモラルな行為もなく、ただ会話をするだけで2万円。

他のサラリーマンは、私とは別口の給料が支払われているのだろうか。

そして、そこでは、一体どんな凄い話術が展開されているのか。

NHKでやっている「日本の話芸」に匹敵するクオリティなのだろうか。

私が、『制御システムのリアルタイム性能』についての話題を振っても、ついてきてくれるんだろうか。

もしかしたら、私が見落しているサブシステムの性能についても、指摘してくれるのかもしれない。

とすれば、「2万円」は、決して高くない。

-----

なんで、私が、キャバクラについて調べているかというと、先日の打ち合わせで、

「次回の定例報告の資料作成については、作成者として江端を『指名』する」という偉い方の指示があったことに起因します。

「指名された私には、一体いくらの「価値」があるんだろう」と考えたのですが、よく分かりません。

そこで、ケーススタディでアプローチしてみることにしました。

そもそも「指名」という「価値」が、一般的に使われている世界はどこだ。

そういえば、「キャバクラ」と称呼される遊興システムに、「ユウコさーん。1番テーブル御指名でーす」というセリフがあったような気がする。

とりあえず、その世界から調べれば、何か分かるかもしれない。

―― と、まあ、そういう経緯に因る訳です。

-----

でも、キャバクラの指名料って、1時間2000円程度なんですね。

これなら、多分私の方が高い。

# 根拠はないけど、そうとでも思わないと、仕事なんぞやっていられない。