0Pricing
Data Science Academy · レッスン

ループなしのベクトル化数学

配列全体に要素単位の演算を適用します

「ループなしのベクトル化数学」はCoddyKit上の無料Data Science Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはData Science Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Data Science Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Math on Whole Arrays

With NumPy you rarely write loops for math. You apply an operation to a whole array at once, and every element updates together. ⚡

The Old Loop Way

In plain Python, doubling numbers means looping one by one. It works, but it's verbose and slow for big datasets.

out = []
for x in nums:
    out.append(x * 2)

The Vectorized Way

NumPy collapses that loop into one line. Vectorization means the operation runs across the entire array in fast compiled code.

arr * 2  # every element doubled

Element-Wise by Default

Add two arrays and NumPy pairs them up position by position. This element-wise behavior is the heart of array math.

np.array([1, 2, 3]) + np.array([10, 20, 30])

Scalars Spread Everywhere

Add a single number to an array and it touches every element. NumPy calls this broadcasting the scalar across the whole grid.

np.array([1, 2, 3]) + 100

All the Operators Work

Subtraction, division, and powers all behave element-wise too. One expression transforms a million numbers in an instant.

arr ** 2  # square each element

Universal Functions

NumPy ships fast math helpers called ufuncs. np.sqrt and np.exp run across an entire array without a single loop.

np.sqrt(np.array([1, 4, 9]))  # 1 2 3

Compare Whole Arrays

Comparisons vectorize too. An expression like arr > 5 returns a boolean array, one True or False per element.

np.array([3, 7, 5]) > 5  # F T F

Why It Runs So Fast

Vectorized code pushes the loop down into optimized C. You skip Python's per-step overhead, so the same work finishes far faster. 🚀

Clearer Code, Too

Beyond speed, vectorized math reads like the formula itself. Less code means fewer bugs and an analysis anyone can follow.

celsius = (fahrenheit - 32) * 5 / 9

Think in Arrays

The mindset shift is simple: stop thinking one number at a time and start thinking in whole arrays. That habit unlocks NumPy's power. 🧠

Quick Check

Let's see what vectorized math returns.

Recap

You learned to drop the loop: vectorized math applies operations element-wise across whole arrays, with scalars broadcast and ufuncs for the rest. Faster and clearer. 🎉

よくある質問

「ループなしのベクトル化数学」レッスンは無料ですか?

はい。「ループなしのベクトル化数学」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Data Science Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Data Science Academyコースには全4レッスンが含まれています。

「ループなしのベクトル化数学」で何を学びますか?

配列全体に要素単位の演算を適用します ブラウザで直接実行するハンズオンコードでData Science Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Data Science Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのData Science Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。

「ループなしのベクトル化数学」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このData Science Academyレッスンでコードを書いて実行できますか?

はい。すべてのData Science Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. Pythonのリストからndarrayへ
  2. Shape、Size、dtype
  3. ループなしのベクトル化数学
  4. 配列のインデックス指定とスライス
← Data Science Academyに戻る